当前位置: 首页>>代码示例>>Java>>正文


Java StmtIterator类代码示例

本文整理汇总了Java中com.hp.hpl.jena.rdf.model.StmtIterator的典型用法代码示例。如果您正苦于以下问题:Java StmtIterator类的具体用法?Java StmtIterator怎么用?Java StmtIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StmtIterator类属于com.hp.hpl.jena.rdf.model包,在下文中一共展示了StmtIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseConfiguration

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
private void parseConfiguration() {
	Iterator<Individual> it = this.model.listIndividuals(D2RQ.Configuration);
	if (it.hasNext()) {
		Resource configResource = it.next();
		Configuration configuration = new Configuration(configResource);
		StmtIterator stmts = configResource.listProperties(D2RQ.serveVocabulary);
		while (stmts.hasNext()) {
			configuration.setServeVocabulary(stmts.nextStatement().getBoolean());
		}			
		stmts = configResource.listProperties(D2RQ.useAllOptimizations);
		while (stmts.hasNext()) {
			configuration.setUseAllOptimizations(stmts.nextStatement().getBoolean());
		}			
		this.mapping.setConfiguration(configuration);

		if (it.hasNext())
			throw new D2RQException("Only one configuration block is allowed");
	}
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:20,代码来源:D2RQReader.java

示例2: initializeCategories

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的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

示例3: main

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
public static void main(String[] args) {
	// Set up the ModelD2RQ using a mapping file
	ModelD2RQ m = new ModelD2RQ("file:doc/example/mapping-iswc.ttl");
	
	// Find anything with an rdf:type of iswc:InProceedings
	StmtIterator paperIt = m.listStatements(null, RDF.type, ISWC.InProceedings);
	
	// List found papers and print their titles
	while (paperIt.hasNext()) {
		Resource paper = paperIt.nextStatement().getSubject();
		System.out.println("Paper: " + paper.getProperty(DC.title).getString());
		
		// List authors of the paper and print their names
		StmtIterator authorIt = paper.listProperties(DC.creator);
		while (authorIt.hasNext()) {
			Resource author = authorIt.nextStatement().getResource();
			System.out.println("Author: " + author.getProperty(FOAF.name).getString());
		}
		System.out.println();
	}
	m.close();
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:23,代码来源:JenaModelExample.java

示例4: getUndefinedResources

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
public Collection<Resource> getUndefinedResources(Model model) {
	Set<Resource> result = new HashSet<Resource>();
	StmtIterator it = model.listStatements();
	while (it.hasNext()) {
		Statement stmt = it.nextStatement();
		if (stmt.getSubject().isURIResource()
				&& stmt.getSubject().getURI().startsWith(namespace)
				&& !resources.contains(stmt.getSubject())) {
			result.add(stmt.getSubject());
		}
		if (stmt.getPredicate().equals(RDF.type)) continue;
		if (stmt.getObject().isURIResource()
				&& stmt.getResource().getURI().startsWith(namespace)
				&& !resources.contains(stmt.getResource())) {
			result.add(stmt.getResource());
		}
	}
	return result;
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:20,代码来源:VocabularySummarizer.java

示例5: parseDownloadMap

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
private void parseDownloadMap(DownloadMap dm, Resource r) {
	StmtIterator stmts;
	stmts = r.listProperties(D2RQ.dataStorage);
	while (stmts.hasNext()) {
		dm.setDatabase(mapping.database(
				stmts.nextStatement().getResource()));
	}
	stmts = r.listProperties(D2RQ.belongsToClassMap);
	while (stmts.hasNext()) {
		dm.setBelongsToClassMap(mapping.classMap(
				stmts.nextStatement().getResource()));
	}
	stmts = r.listProperties(D2RQ.contentDownloadColumn);
	while (stmts.hasNext()) {
		dm.setContentDownloadColumn(stmts.nextStatement().getString());
	}
	stmts = r.listProperties(D2RQ.mediaType);
	while (stmts.hasNext()) {
		dm.setMediaType(stmts.nextStatement().getString());
	}
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:22,代码来源:D2RQReader.java

示例6: getRDFNodes

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
public List<RDFNode> getRDFNodes(Resource r, Property p, NodeType acceptableNodes) {
	List<RDFNode> result = new ArrayList<RDFNode>();
	StmtIterator it = r.listProperties(p);
	while (it.hasNext()) {
		Statement stmt = it.next();
		remainingTriples.remove(stmt);
		if (acceptableNodes.isTypeOf(stmt.getObject())) {
			result.add(stmt.getObject());
		} else {
			if (acceptableNodes.coerce(stmt.getObject()) != null) {
				result.add(acceptableNodes.coerce(stmt.getObject()));
			}
			report.report(acceptableNodes.ifNot, r, p, stmt.getObject());
		}
	}
	Collections.sort(result, RDFComparator.getRDFNodeComparator());
	return result;
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:19,代码来源:R2RMLReader.java

示例7: runQueryOnInstance

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
/**
 * Runs a given Jena Query on a given instance and adds the inferred triples
 * to a given Model.
 * @param queryWrapper  the wrapper of the CONSTRUCT query to execute
 * @param queryModel  the query Model
 * @param newTriples  the Model to write the triples to
 * @param instance  the instance to run the inferences on
 * @param checkContains  true to only call add if a Triple wasn't there yet
 * @return true if changes were done (only meaningful if checkContains == true)
 */
public static boolean runQueryOnInstance(QueryWrapper queryWrapper, Model queryModel, Model newTriples, Resource instance, boolean checkContains) {
	boolean changed = false;
	QueryExecution qexec = ARQFactory.get().createQueryExecution(queryWrapper.getQuery(), queryModel);
	QuerySolutionMap bindings = new QuerySolutionMap();
	bindings.add(SPIN.THIS_VAR_NAME, instance);
	Map<String,RDFNode> initialBindings = queryWrapper.getTemplateBinding();
	if(initialBindings != null) {
		for(String varName : initialBindings.keySet()) {
			RDFNode value = initialBindings.get(varName);
			bindings.add(varName, value);
		}
	}
	qexec.setInitialBinding(bindings);
	Model cm = qexec.execConstruct();
	StmtIterator cit = cm.listStatements();
	while(cit.hasNext()) {
		Statement s = cit.nextStatement();
		if(!checkContains || !queryModel.contains(s)) {
			changed = true;
			newTriples.add(s);
		}
	}
	return changed;
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:35,代码来源:SPINInferencesWithoutConstructor.java

示例8: getNumberOfLinks

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
private Integer getNumberOfLinks(String nif) {
    Model model = ModelFactory.createDefaultModel();
    model.read(new ByteArrayInputStream(nif.getBytes()), null, "TTL");
    StmtIterator iter = model.listStatements();

    Integer result = 0;

    while (iter.hasNext()) {
        Statement stm = iter.nextStatement();
        if (NIF21Format.RDF_PROPERTY_IDENTREF.equals(stm.getPredicate().toString())) {
            result += 1;
        }
    }

    return result;
}
 
开发者ID:freme-project,项目名称:freme-ner,代码行数:17,代码来源:FremeNERLabelMatch.java

示例9: getAllEntityEvents

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
static ArrayList<String> getAllEntityEvents (Dataset dataset, String entity) {
    ArrayList<String> events = new ArrayList<String>();
    Iterator<String> it = dataset.listNames();
    while (it.hasNext()) {
        String name = it.next();
        if (!name.equals(instanceGraph) && (!name.equals(provenanceGraph))) {
            Model namedModel = dataset.getNamedModel(name);
            StmtIterator siter = namedModel.listStatements();
            while (siter.hasNext()) {
                Statement s = siter.nextStatement();
                String object = getObjectValue(s).toLowerCase();
                if (object.indexOf(entity.toLowerCase()) > -1) {
                    String subject = s.getSubject().getURI();
                    if (!events.contains(subject)) {
                        events.add(subject);
                    }
                }
            }
        }
    }
    return events;
}
 
开发者ID:newsreader,项目名称:StreamEventCoreference,代码行数:23,代码来源:TrigUtil.java

示例10: getAllNoteDescriptors

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
public ResourceDescriptor[] getAllNoteDescriptors(String outlineUri) {
    Model outlineModel;
    try {
        outlineModel = MindRaider.outlineCustodian.getModel(outlineUri);
        Property property = RDF.type;
        String literal = MindRaiderConstants.MR_OWL_CLASS_CONCEPT;
        StmtIterator i = outlineModel.listStatements((com.hp.hpl.jena.rdf.model.Resource)null,property,outlineModel.getResource(literal));
        ArrayList<String> noteUris=new ArrayList<String>();
        while(i.hasNext()) {
            Statement s=i.nextStatement();
            noteUris.add(s.getSubject().getURI());
        }
        return getDescriptorsForNoteUris(true, outlineModel, noteUris.toArray(new String[noteUris.size()]));
    } catch (Exception e) {
        logger.debug("Unable to get resource descriptors",e); // {{debug}}
    }

    return null;
}
 
开发者ID:dvorka,项目名称:mindraider,代码行数:20,代码来源:OutlineCustodian.java

示例11: getFolderUris

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
/**
 * Get URIs of all folders.
 *
 * @return the uri String array
 */
public String[] getFolderUris() {
    // TODO cope with discarded folders

    ArrayList<String> result = new ArrayList<String>();
    StmtIterator i = labelsModel.getModel().listStatements(null, RDF.type,
            labelsModel.getResource(MindRaiderConstants.MR_OWL_CLASS_FOLDER));
    while (i.hasNext()) {
        String folderUri = i.nextStatement().getSubject().getURI();
        if (!LABEL_TRASH_URI.equals(folderUri)) {
            result.add(folderUri);
        }
    }

    if (result.size() == 0) {
        return null;
    }

    return (String[]) (result.toArray(new String[result.size()]));
}
 
开发者ID:dvorka,项目名称:mindraider,代码行数:25,代码来源:LabelCustodian.java

示例12: createStatement

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
/**
 * Create a statement.
 * 
 * @param subject
 *            the resource
 * @param predicateUri
 *            the predicate url
 * @param objectUri
 *            the object url
 * @param literal
 *            the literal flag
 * @return a Statement object
 */
public Statement createStatement(Resource subject, String predicateUri,
        String objectUri, boolean literal) {
    RDFNode objectResource;
    Property predicateResource = model.createProperty(predicateUri);

    if (literal) {
        objectResource = model.createLiteral(objectUri);
    } else {
        objectResource = model.createResource(objectUri);
    }
    subject.addProperty(predicateResource, objectResource);

    StmtIterator i = model.listStatements(subject, predicateResource,
            objectResource);
    if (i.hasNext()) {
        return i.nextStatement();
    }
    JOptionPane.showMessageDialog(MindRaider.mainJFrame,
            "Unable to fetch statement.", "Error",
            JOptionPane.ERROR_MESSAGE);
    return null;
}
 
开发者ID:dvorka,项目名称:mindraider,代码行数:36,代码来源:RdfModel.java

示例13: getPropertyValues

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
<T> List<T> getPropertyValues(final Resource resource, final String property, final Function<Statement,Optional<T>> filter) {
	Preconditions.checkState(this.model!=null);
	final StmtIterator stmts = resource.listProperties(this.model.createProperty(property));
	try {
		final List<T> values=Lists.newArrayList();
		while(stmts.hasNext()) {
			final Statement st=stmts.nextStatement();
			final Optional<T> result = filter.apply(st);
			if(result.isPresent()) {
				values.add(result.get());
			}
		}
		return values;
	} finally {
		stmts.close();
	}
}
 
开发者ID:SmartDeveloperHub,项目名称:sdh-vocabulary,代码行数:18,代码来源:ModuleHelper.java

示例14: execute

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
@Override
public Void execute() throws RuntimeException {
	final StmtIterator iterator=
		this.model.
			listStatements(
				null,
				this.model.createProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
				this.model.createProperty(this.propertyName));
	try {
		while(iterator.hasNext()) {
			handler(iterator.next());
		}
		return null;
	} finally {
		iterator.close();
	}
}
 
开发者ID:SmartDeveloperHub,项目名称:sdh-vocabulary,代码行数:18,代码来源:LexvoDataSource.java

示例15: isDisambiguationResource

import com.hp.hpl.jena.rdf.model.StmtIterator; //导入依赖的package包/类
public boolean isDisambiguationResource(String uri) {
    
    if(!linksLoaded){
        System.out.println(Settings.EN_DBPEDIA_DISAMBIGUATION_DATASET);
        System.out.println(Settings.DE_DBPEDIA_DISAMBIGUATION_DATASET);
        System.out.println(Settings.NL_DBPEDIA_DISAMBIGUATION_DATASET);
        InputStream in1 = FileManager.get().open( Settings.EN_DBPEDIA_DISAMBIGUATION_DATASET );
        InputStream in2 = FileManager.get().open( Settings.DE_DBPEDIA_DISAMBIGUATION_DATASET );
        InputStream in3 = FileManager.get().open( Settings.NL_DBPEDIA_DISAMBIGUATION_DATASET );
        model.read(in1, null, "N-TRIPLES");
        System.out.println("Loaded English disambiguation dataset.");
        model.read(in2, null, "N-TRIPLES");
        System.out.println("Loaded German disambiguation dataset.");
        model.read(in3, null, "N-TRIPLES");
        System.out.println("Loaded Dutch disambiguation dataset.");
        linksLoaded = true;
    }
    
    StmtIterator iter = model.listStatements( new SimpleSelector(
            ResourceFactory.createResource(uri), 
            ResourceFactory.createProperty("http://dbpedia.org/ontology/wikiPageDisambiguates"), 
                    (RDFNode)null));
    
    return iter.hasNext();
}
 
开发者ID:entityclassifier-eu,项目名称:entityclassifier-core,代码行数:26,代码来源:DisambiguationPageValidator.java


注:本文中的com.hp.hpl.jena.rdf.model.StmtIterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。