當前位置: 首頁>>代碼示例>>Java>>正文


Java RDFNode.isResource方法代碼示例

本文整理匯總了Java中com.hp.hpl.jena.rdf.model.RDFNode.isResource方法的典型用法代碼示例。如果您正苦於以下問題:Java RDFNode.isResource方法的具體用法?Java RDFNode.isResource怎麽用?Java RDFNode.isResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hp.hpl.jena.rdf.model.RDFNode的用法示例。


在下文中一共展示了RDFNode.isResource方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initializeCategories

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public Set<String> initializeCategories() {
	Model model = ModelFactory.createDefaultModel();
	model.read("/home/zwicklbauer/HDTGeneration/skos_categories_en.nt");
	StmtIterator it = model.listStatements();
	Set<String> set = new HashSet<String>();
	
	System.out.println("Los gehts");
	while (it.hasNext()) {
		Statement s = it.next();
		Resource r = s.getSubject();
		Property p = s.getPredicate();
		RDFNode n = s.getObject();
		if (p.getURI().equalsIgnoreCase(
				"http://www.w3.org/2004/02/skos/core#broader")
				&& n.isResource()) {
			Resource target = n.asResource();
			if(!hasSubCategory(target.getURI())) 
			set.add(target.getURI());
			if(!hasSubCategory(r.getURI())) 
			set.add(r.getURI());
		}
	}
	return set;
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:25,代碼來源:DbpediaGraphModification.java

示例2: addSkosBroaderToGraph

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
private void addSkosBroaderToGraph() {
	Model m = ModelFactory.createDefaultModel();
	m.read(SKOSBROADER);
	StmtIterator it = m.listStatements();
	while (it.hasNext()) {
		Statement s = it.next();
		Resource subject = s.getSubject();
		Property pra = s.getPredicate();
		RDFNode object = s.getObject();
		if (object.isResource()) {
			Resource obj = object.asResource();
			if (pra.isResource()
					&& obj.getURI().startsWith(
							"http://dbpedia.org/resource/")) {
				if (!subject.getURI().equalsIgnoreCase(obj.getURI())) {
					graph.addVertex(subject.getURI());
					graph.addVertex(obj.getURI());
					graph.addEdge(subject.getURI(), obj.getURI());
				}
			}
		}
	}
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:24,代碼來源:CreateRandomDBpediaModel.java

示例3: sportsTeamsSurfaceForms

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public void sportsTeamsSurfaceForms() {
	Model m = ModelFactory.createDefaultModel();

	m.read(INSTANCEMAPPINGTYPES_NT);

	StmtIterator it = m.listStatements();

	while (it.hasNext()) {
		Statement s = it.next();
		Resource subject = s.getSubject();
		RDFNode object = s.getObject();

		if (object.isResource()) {
			Resource obj = object.asResource();
			if (obj.getURI().equalsIgnoreCase("http://dbpedia.org/ontology/SportsTeam")) {
				teams.add(subject.getURI());
			}
		}
	}
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:21,代碼來源:CreateDBpediaIndexV2.java

示例4: getParents

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
/**
 * Look up <code>uri</code> in the ontology and return a list of parent
 * concepts (URIs). Synonyms are not considered. The list contains no
 * duplicates. Never returns <code>null</code>.
 * 
 * @param term
 *            term to be looked up
 * @return a list of parent concepts URIs
 */
// TODO add all synonyms of the parents to the result
public List<String> getParents(String uri) {
	Resource resource = model.getResource(uri);
	if (resource == null)
		return Collections.emptyList();
	
	List<String> result = new ArrayList<String>();

	StmtIterator parent = resource.listProperties(RDFS.subClassOf);
	while(parent.hasNext()) {
		RDFNode child = parent.nextStatement().getObject();

		if (child.isResource() && !child.isAnon() /*&& !((Resource)child).hasLiteral(Jura.invisible, true)*/) {
			result.add(((Resource)child).getURI());
		}
	}

	return result;
}
 
開發者ID:ag-csw,項目名稱:ExpertFinder,代碼行數:29,代碼來源:OntologyIndex.java

示例5: getRequest

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
private List getRequest(Resource pcho)
{
    List l = new ArrayList();
    StmtIterator iter = pcho.listProperties();
    while ( iter.hasNext() )
    {
        Statement stmt = iter.nextStatement();
        RDFNode   node = stmt.getObject();
        String    uri  = stmt.getPredicate().getURI();
        if ( node.isResource() || !_fields.containsKey(uri) ) { continue; }

        String    prop = getQName(stmt.getPredicate());
        String    value = node.asLiteral().getString();
        String[]  vocs  = _fields.get(uri);
        for ( String key : normalizeInternal(value) )
        {
            Map m = new HashMap(3);
            m.put("originalField", prop + ";" + value);
            m.put("value", key);
            m.put("vocabularies",  vocs);
            l.add(m);
        }
    }
    return l;
}
 
開發者ID:hugomanguinhas,項目名稱:europeana,代碼行數:26,代碼來源:EnrichmentAPI.java

示例6: enrichImpl

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
private void enrichImpl(StmtIterator iter, Collection<Resource> toRemove, CSVWriter printer)
{
    for ( Statement stmt : iter.toList())
    {
        RDFNode  node   = stmt.getObject();
        if ( !node.isResource() ) { continue; }

        Resource target = node.asResource();
        if ( !isEntity(target)  ) { continue; }

        String   label  = getLabel(target);
        if ( label == null      ) { continue; }

        printEnrichment(stmt, label, printer);

        stmt.changeObject(label);
        toRemove.add(target);
    }
}
 
開發者ID:hugomanguinhas,項目名稱:europeana,代碼行數:20,代碼來源:DatasetProcessor.java

示例7: binding

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
@Override
public void binding(String varName, RDFNode value) {
    // If, for a particular solution, a variable is unbound, no binding element for that variable is included in the result element.
    if (value == null)
        return;

    try {
        // start binding element
        atts.clear();
        atts.addAttribute(dfNamespace, dfAttrVarName, dfAttrVarName, "CDATA", varName);
        handler.startElement(dfNamespace, dfBinding, dfBinding, atts);

        // binding value
        if (value.isLiteral())
            literal((Literal) value);
        else if (value.isResource())
            resource((Resource) value);

        // end binding element
        handler.endElement(dfNamespace, dfBinding, dfBinding);
    } catch (SAXException ex) {
    }
}
 
開發者ID:ljo,項目名稱:exist-sparql,代碼行數:24,代碼來源:JenaResultSet2Sax.java

示例8: getVariables

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
private List<String> getVariables(Model model, Resource service_resource) {
	
	Property has_variable_property = model.getProperty(Namespaces.KARMA + "hasVariable");

	List<String> variables = new ArrayList<String>();
	NodeIterator nodeIterator = null;
	RDFNode node = null;

	// hasAttribute
	nodeIterator = model.listObjectsOfProperty(service_resource, has_variable_property);
	while ( nodeIterator.hasNext()) {
		node = nodeIterator.next();
		
		if (!node.isResource()) {
			logger.info("object of the hasAttribute property is not a resource.");
			continue;
		}
		
		variables.add(node.asResource().getLocalName());
	}
	
	return variables;

}
 
開發者ID:therelaxist,項目名稱:spring-usc,代碼行數:25,代碼來源:WebServiceLoader.java

示例9: printProperty

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public void printProperty(Property property, RDFNode term) {
	if (term == null) return;
	if (term.isResource()) {
		printPropertyTurtle(term != null, property, toTurtle(term.asResource()));
	} else {
		printPropertyTurtle(term != null, property, toTurtle(term.asLiteral()));
	}
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:9,代碼來源:PrettyTurtleWriter.java

示例10: convertIntoTable

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
private static StringMatrix convertIntoTable(
		PrefixMapping prefixMap, ResultSet results) {
	StringMatrix table = new StringMatrix();
	int rowCount = 0;
	while (results.hasNext()) {
		rowCount++;
		QuerySolution soln = results.nextSolution();
		Iterator<String> varNames = soln.varNames();
		while (varNames.hasNext()) {
			String varName = varNames.next();
			int colCount = -1;
			if (table.hasColumn(varName)) {
				colCount = table.getColumnNumber(varName);
			} else {
				colCount = table.getColumnCount() + 1;
				table.setColumnName(colCount, varName);
			}
			RDFNode node = soln.get(varName);
			if (node != null) {
				if (node.isResource()) {
					Resource resource = (Resource)node;
					table.set(rowCount, colCount,
						resource.getURI()
					);
				} else if (node.isLiteral()) {
					Literal literal = (Literal)node;
					table.set(rowCount, colCount, "" + literal.getValue());
				}
			}
		}
	}
	return table;
}
 
開發者ID:wikipathways,項目名稱:GPML2RDF,代碼行數:34,代碼來源:SPARQLHelper.java

示例11: toIdentifier

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
/**
 * This ID may be either a URI or a literal.
 * 
 * @param o
 * @return
 */
private static String toIdentifier(RDFNode o) {
	if (o.isResource())
		return o.isAnon() ? "http://rocker.aksw.org/"
				+ "blanknode/BN" + DigestUtils.shaHex(o.toString())
				: ((Resource) o).getURI();
	else
		return o.as(Literal.class).getString();
}
 
開發者ID:AKSW,項目名稱:rocker,代碼行數:15,代碼來源:DataIndexer.java

示例12: createGraph

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public UndirectedGraph<String, DefaultEdge> createGraph() {
	Model model = ModelFactory.createDefaultModel();
	model.read("/home/zwicklbauer/HDTGeneration/skos_categories_en.nt");
	StmtIterator it = model.listStatements();
	UndirectedGraph<String, DefaultEdge> graph = new MiGrafo();
	Set<String> set = new HashSet<String>();

	int counter = 0;
	while (it.hasNext()) {
		Statement s = it.next();
		Resource r = s.getSubject();
		Property p = s.getPredicate();
		RDFNode n = s.getObject();
		if (p.getURI().equalsIgnoreCase(
				"http://www.w3.org/2004/02/skos/core#broader")
				&& n.isResource()) {
			set.add(r.getURI());
			Resource target = n.asResource();
			set.add(target.getURI());
			if (!graph.containsVertex(r.getURI())) {
				graph.addVertex(r.getURI());
			}
			if (!graph.containsVertex(target.getURI())) {
				graph.addVertex(target.getURI());
			}
			graph.addEdge(r.getURI(), target.getURI());
			if (counter % 10000 == 0) {
				System.out.println(counter);
			}
			counter++;
		}
	}
	return graph;
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:35,代碼來源:Sampling.java

示例13: fillRelationsIndex

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public void fillRelationsIndex() {
	Model m = ModelFactory.createDefaultModel();

	m.read(MAPPINGPROPERTIES);

	StmtIterator it = m.listStatements();

	while (it.hasNext()) {
		Statement s = it.next();
		Resource subject = s.getSubject();
		Property pra = s.getPredicate();
		RDFNode object = s.getObject();
		if (object.isResource()) {
			Resource obj = object.asResource();
			if (pra.isResource()
					&& obj.getURI().startsWith(
							"http://dbpedia.org/resource/")) {
				if (!relationmap.containsKey(subject.getURI())) {
					LinkedList<String> list = new LinkedList<String>();
					relationmap.put(subject.getURI(), list);
				}
				LinkedList<String> l = relationmap.get(subject.getURI());
				l.add(pra.getURI().replaceAll(
						"http://dbpedia.org/ontology/", "dbpediaOnt/")
						+ ":::"
						+ obj.getURI().replaceAll(
								"http://dbpedia.org/resource/",
								"dbpediaRes/"));

			}
		}
	}
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:34,代碼來源:CreateDBPediaIndex.java

示例14: fillPropertiesIndex

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public void fillPropertiesIndex() {
	Model m = ModelFactory.createDefaultModel();

	m.read(INFOBOXPROPERTIES);

	StmtIterator it = m.listStatements();

	while (it.hasNext()) {
		Statement s = it.next();
		Resource subject = s.getSubject();
		Property pra = s.getPredicate();
		RDFNode object = s.getObject();
		if (object.isResource()) {
			Resource obj = object.asResource();
			if (pra.isResource() && obj.getURI().startsWith("http://dbpedia.org/resource/")) {
				if (!relationmap.containsKey(subject.getURI())) {
					LinkedList<String> list = new LinkedList<String>();
					relationmap.put(subject.getURI(), list);
				}
				LinkedList<String> l = relationmap.get(subject.getURI());
				l.add(pra.getURI().replaceAll("http://dbpedia.org/property/", "dbpediaOnt/") + ":::"
						+ obj.getURI().replaceAll("http://dbpedia.org/resource/", "dbpediaRes/"));

			}
		}
	}
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:28,代碼來源:CreateDBpediaIndexV2.java

示例15: fillRelationsIndex

import com.hp.hpl.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public void fillRelationsIndex() {
	Model m = ModelFactory.createDefaultModel();

	m.read(MAPPINGPROPERTIES);

	StmtIterator it = m.listStatements();

	while (it.hasNext()) {
		Statement s = it.next();
		Resource subject = s.getSubject();
		Property pra = s.getPredicate();
		RDFNode object = s.getObject();
		if (object.isResource()) {
			Resource obj = object.asResource();
			if (pra.isResource() && obj.getURI().startsWith("http://dbpedia.org/resource/")) {
				if (!relationmap.containsKey(subject.getURI())) {
					LinkedList<String> list = new LinkedList<String>();
					relationmap.put(subject.getURI(), list);
				}
				LinkedList<String> l = relationmap.get(subject.getURI());
				l.add(pra.getURI().replaceAll("http://dbpedia.org/ontology/", "dbpediaOnt/") + ":::"
						+ obj.getURI().replaceAll("http://dbpedia.org/resource/", "dbpediaRes/"));

			}
		}
	}
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:28,代碼來源:CreateDBpediaIndexV2.java


注:本文中的com.hp.hpl.jena.rdf.model.RDFNode.isResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。