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


Java Statement.getPredicate方法代碼示例

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


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

示例1: initializeCategories

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的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: showThisStatement

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
public boolean showThisStatement(Statement statement) {
    Property predicate = statement.getPredicate();
    if (predicate.equals(RDF.type) || predicate.equals(DC.date) || predicate.equals(RDFS.label)
            || predicate.equals(RDFS.comment) || predicate.equals(MindRaiderVocabulary.isDiscarded)
            || predicate.equals(MindRaiderVocabulary.xlinkHref)
            || predicate.equals(MindRaiderVocabulary.flagProperty)) {
        return false;
    }

    // do not show trash content
    String uri = statement.getSubject().getURI();
    if (uri != null && uri.endsWith(NoteCustodian.NOTEBOOK_TRASH_LOCAL_NAME)) {
        return false;
    }

    return true;
}
 
開發者ID:dvorka,項目名稱:mindraider,代碼行數:18,代碼來源:BriefFacet.java

示例3: addSkosBroaderToGraph

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的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

示例4: mergeResources

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
public static void mergeResources(Resource src, Resource trg)
{
	Property sameAs = src.getModel().getProperty(URI_SAMEAS);

	StmtIterator iter = src.listProperties();
	while ( iter.hasNext() )
	{
		Statement stmt = iter.nextStatement();

		Property p = stmt.getPredicate();
		if ( p.equals(sameAs) ) { continue; }

		trg.addProperty(p, stmt.getObject());
		iter.remove();
	}
}
 
開發者ID:hugomanguinhas,項目名稱:europeana,代碼行數:17,代碼來源:VocsUtils.java

示例5: dumpStatement

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
void dumpStatement(Statement stmt) {
	Resource  subject   = stmt.getSubject();
	Property  predicate = stmt.getPredicate();
	RDFNode   object    = stmt.getObject();
	System.out.print(subject + " " + predicate + " ");
	if (object instanceof Resource) {
		System.out.print(object);
	} else { // object is a literal
		System.out.print(" \"" + object + "\"");
	}
	System.out.println(" .");
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:13,代碼來源:ModelAPITest.java

示例6: showThisStatement

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
public boolean showThisStatement(Statement statement) {
    Property predicate = statement.getPredicate();
    if (predicate.equals(RDF.type) || predicate.equals(MindRaiderVocabulary.isDiscarded)
            || predicate.equals(MindRaiderVocabulary.flagProperty)) {
        return false;
    }
    // do not show trash content
    if (statement.getSubject().getURI().endsWith(NoteCustodian.NOTEBOOK_TRASH_LOCAL_NAME)) {
        return false;
    }

    return true;
}
 
開發者ID:dvorka,項目名稱:mindraider,代碼行數:14,代碼來源:NormalFacet.java

示例7: showThisStatement

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
public boolean showThisStatement(Statement statement) {
    if (briefFacet.showThisStatement(statement)) {
        Property predicate = statement.getPredicate();
        if (!predicate.equals(MindRaiderVocabulary.attachment)) {
            return true;
        }
    }

    return false;
}
 
開發者ID:dvorka,項目名稱:mindraider,代碼行數:11,代碼來源:NoAttachmentsFacet.java

示例8: createGraph

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的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

示例9: addCategoriesToGraph

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
private void addCategoriesToGraph() {
	Model m = ModelFactory.createDefaultModel();
	m.read(ARTICLECATEGORIES);
	StmtIterator it = m.listStatements();
	int counter = 0;
	while (it.hasNext()) {
		if (counter % 10000 == 0) {
			System.out.println(counter);
		}
		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());
				}
			}
		}
	}
	counter++;
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:29,代碼來源:CreateRandomDBpediaModel.java

示例10: fillRelationsIndex

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的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

示例11: fillPropertiesIndex

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的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

示例12: fillRelationsIndex

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的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

示例13: doConversion

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
private void doConversion(Model model) throws JenaException {
  StatementHandler totm = new ToTMStatementHandler();
  AResourceWrapper subjw = new AResourceWrapper();
  AResourceWrapper propw = new AResourceWrapper();
  AResourceWrapper objtw = new AResourceWrapper();
  ALiteralWrapper litlw = new ALiteralWrapper();

  ResIterator it = model.listSubjects();
  while (it.hasNext()) {
    Resource subject = (Resource) it.next();

    StmtIterator it2 = subject.listProperties(); // get all statements
    while (it2.hasNext()) {
      Statement stmt = (Statement) it2.next();

      subjw.resource = stmt.getSubject();
      propw.resource = stmt.getPredicate();

      RDFNode obj = stmt.getObject();
      if (obj instanceof Resource) {
        objtw.resource = (Resource) obj;
        totm.statement(subjw, propw, objtw);
      } else {
        litlw.literal = (Literal) obj;
        totm.statement(subjw, propw, litlw);
      }
    }
  }
}
 
開發者ID:ontopia,項目名稱:ontopia,代碼行數:30,代碼來源:RDFToTopicMapConverter.java

示例14: copyFromTdb

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
private void copyFromTdb( Dataset dataset ) throws RepositoryException {
	ValueFactory vf = rc.getValueFactory();

	if ( dataset.supportsTransactions() ) {
		dataset.begin( ReadWrite.READ );
	}

	// Get model inside the transaction
	Model model = dataset.getDefaultModel();
	StmtIterator si = model.listStatements();

	try {
		rc.begin();
		while ( si.hasNext() ) {
			Statement stmt = si.next();
			com.hp.hpl.jena.rdf.model.Resource rsr = stmt.getSubject();
			Property pred = stmt.getPredicate();
			RDFNode val = stmt.getObject();
			Node valnode = val.asNode();
			
			Resource sub;
			try {
				sub = ( rsr.isAnon()
						? vf.createBNode( valnode.getBlankNodeLabel() )
						: vf.createURI( rsr.toString() ) );
			}
			catch ( UnsupportedOperationException uoo ) {
				log.warn( uoo, uoo );
				continue;
			}
			
			URI pred2 = vf.createURI( pred.toString() );
			Value val2;

			if ( val.isLiteral() ) {
				Literal lit = val.asLiteral();
				String dtstr = lit.getDatatypeURI();
				URI dt = ( null == dtstr ? null : vf.createURI( dtstr ) );
				String langstr = lit.getLanguage();

				if ( null == dt ) {
					if ( langstr.isEmpty() ) {
						val2 = vf.createLiteral( lit.toString() );
					}
					else {
						val2 = vf.createLiteral( lit.toString(), langstr );
					}
				}
				else {
					val2 = vf.createLiteral( lit.toString(), dt );
				}
			}
			else {
				if ( val.isAnon() ) {
					val2 = vf.createBNode( valnode.getBlankNodeLabel() );
				}
				else {
					val2 = vf.createURI( val.toString() );
				}
			}
			rc.add( sub, pred2, val2 );
		}
		rc.commit();
	}
	catch ( RepositoryException re ) {
		rc.rollback();
		throw re;
	}
	finally {
		if ( dataset.supportsTransactions() ) {
			dataset.end();
		}
	}
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:75,代碼來源:JenaEngine.java

示例15: isType

import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
private boolean isType(Statement stmt, Resource type)
{
    Property predicate = stmt.getPredicate();
    return ((predicate.getURI().equals(RDF_TYPE)) && (type.equals(stmt.getObject())));
}
 
開發者ID:hugomanguinhas,項目名稱:europeana,代碼行數:6,代碼來源:EDMXMLWriter.java


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