本文整理汇总了Java中com.hp.hpl.jena.rdf.model.ResIterator.hasNext方法的典型用法代码示例。如果您正苦于以下问题:Java ResIterator.hasNext方法的具体用法?Java ResIterator.hasNext怎么用?Java ResIterator.hasNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.ResIterator
的用法示例。
在下文中一共展示了ResIterator.hasNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRowToMODEL
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
private void addRowToMODEL(List<Statement> sa, String key, String puri) {
for (Statement s : sa) {
if (MODEL.contains(s)) {
continue;
}
// add to existing resource with same key if exists
if (s.getPredicate().getLocalName().equals(key)) {
ResIterator it = MODEL.listResourcesWithProperty(s.getPredicate(), s.getObject());
if (it.hasNext()) { // assume all members are equal
Resource rsc = it.nextResource(); // get parent
Property p = ResourceFactory.createProperty(genOURI(), puri);
Statement st = ResourceFactory.createStatement(rsc, p, s.getSubject());
MODEL.add(st);
continue;
}
}
MODEL.add(s);
}
}
示例2: getChildren
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
/**
* Look up <code>uri</code> in the ontology and return a list of child
* 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 child concepts URIs
*/
// TODO add all synonyms of the children to the result
public List<String> getChildren(String uri) {
Resource resource = model.getResource(uri);
if (resource == null)
return Collections.emptyList();
List<String> result = new ArrayList<String>();
ResIterator child = model.listResourcesWithProperty(RDFS.subClassOf, resource);
while(child.hasNext()) {
Resource parent = child.nextResource();
// if (!parent.hasLiteral(Jura.invisible, true)) {
result.add(parent.getURI());
// }
}
return result;
}
示例3: getClasses
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
protected Set<Resource> getClasses(Model readModel) {
ResIterator iterator = readModel.listSubjectsWithProperty(RDF.type, RDFS.Class);
Resource r;
Set<Resource> classes = new HashSet<Resource>();
while (iterator.hasNext()) {
r = iterator.next();
if (!r.isAnon()) {
classes.add(r);
}
}
iterator = readModel.listSubjectsWithProperty(RDF.type, OWL.Class);
while (iterator.hasNext()) {
r = iterator.next();
if (!r.isAnon()) {
classes.add(r);
}
}
return classes;
}
示例4: main
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
public static final void main(String[] args)
{
PrintStream out = System.out;
Model m = loadModel(FILE_AGENTS_DBPEDIA_SRC);
Set<Resource> noLang = new HashSet();
Set<Resource> dupLbl = new HashSet();
Set<Resource> dupEnLbl = new HashSet();
ResIterator iter = m.listSubjects();
while ( iter.hasNext() ) { checkResource(iter.next(), noLang, dupEnLbl, dupLbl); }
//print
out.println("Resource with no language: " + noLang.size());
//for ( Resource rsrc : noLang ) { out.println(rsrc.getURI()); }
out.println("Resource with duplicate en labels: " + dupEnLbl.size());
//for ( Resource rsrc : dupEnLbl ) { out.println(rsrc.getURI()); }
out.println("Resource with duplicate labels in other langs: " + dupLbl.size());
//for ( Resource rsrc : dupLbl ) { out.println(rsrc.getURI()); }
}
示例5: fetchLabels
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
private void fetchLabels(Model m)
{
Map<String,String> map = new HashMap();
Property p = m.getProperty(SKOS_PREF_LABEL);
ResIterator rIter = m.listResourcesWithProperty(m.getProperty(RDF_TYPE));
while ( rIter.hasNext() )
{
Resource r = rIter.next();
fetchAlternatives(map, r);
StmtIterator sIter = r.listProperties(p);
while ( sIter.hasNext() )
{
Statement stmt = sIter.next();
put(stmt.getSubject(), getKey(stmt.getString(), map));
}
map.clear();
}
}
示例6: enrichImpl
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
private void enrichImpl(ResIterator iter, CSVWriter p)
{
while (iter.hasNext())
{
Resource rsrc = iter.next();
System.out.print("Enriching resource: " + rsrc.getURI());
List<Map> l = _api.enrich(rsrc);
if ( l == null ) { System.out.println(); continue; }
int count = 0;
for ( Map m : l )
{
count++;
p.print(rsrc.getURI(), m.get("field")
, m.get("enrichment"), "", m.get("value"));
}
System.out.println(" [" + count + "]");
}
}
示例7: fixSubjects
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
private Model fixSubjects(Model m)
{
Collection<String> sa = new HashSet();
ResIterator iter = m.listSubjects();
while ( iter.hasNext() )
{
String uri = iter.next().getURI();
if ( PATTERN_WIKIDATA.matcher(uri).matches() ) { sa.add(uri); }
}
for ( String s : sa )
{
String sNew = getNew(s);
if ( sNew == null ) { continue; }
ResourceUtils.renameResource(m.getResource(s), sNew);
}
return m;
}
示例8: analyse
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
public ObjectStat analyse(File srcList, File src, File dst) throws IOException
{
Collection<String> c = loadDataURLs(srcList, PATTERN_LEXVO);
Model m = ModelFactory.createDefaultModel();
loadModel(m, src, null);
ObjectStat stat = new ObjectStat("Lexvo", true, false, true);
stat.addPropertyValue(m.getProperty("http://www.w3.org/2008/05/skos-xl#literalForm"));
ResIterator iter = m.listSubjects();
while ( iter.hasNext() )
{
Resource r = iter.next();
if ( !c.contains(r.getURI()) ) { continue; }
stat.newObject(r);
}
if ( dst != null ) { stat.print(new PrintStream(dst, "UTF-8")); }
return stat;
}
示例9: getListByName
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
@Override
public ArrayList<PlaceDTO> getListByName(String nombre) {
ArrayList<PlaceDTO> result = new ArrayList<>();
Resource mibarrio_Library = model.createResource(mibarrio + "Library");
ResIterator rIter = this.model.listSubjectsWithProperty(RDF.type,mibarrio_Library);
while (rIter.hasNext() && result.size() < 10){
Resource r = rIter.nextResource();
Property schema_name = this.model.createProperty(schema+"name");
Property schema_description = this.model.createProperty(schema+"description");
if (r.hasProperty(schema_name)){
String placeName = r.getRequiredProperty( schema_name ).getString();
if (placeName.toLowerCase().contains(nombre.toLowerCase())){
double[] location = this.getPlaceCoordinates(placeName.replace(" ",""));
String placeDescription = "";
if(r.hasProperty(schema_description)){
placeDescription = r.getRequiredProperty( schema_description).getString();
}
PlaceDTO place = new PlaceDTO(placeName,location[0],location[1]);
result.add(place);
}
}
}
return result;
}
示例10: ToscaAdapter
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
public ToscaAdapter( Model adapterTBox, Resource adapterABox, ToscaMDBSender sender) {
this.sender = sender;
this.uuid = UUID.randomUUID().toString();
this.adapterTBox = adapterTBox;
this.adapterABox = adapterABox;
Resource adapterType = null;
ResIterator adapterIterator = adapterTBox.listSubjectsWithProperty(RDFS.subClassOf, MessageBusOntologyModel.classAdapter);
if (adapterIterator.hasNext()) {
adapterType = adapterIterator.next();
}
this.adapterABox.addProperty(RDF.type, adapterType);
this.adapterABox.addProperty(RDFS.label, adapterABox.getLocalName());
this.adapterABox.addProperty(RDFS.comment, "An adapter for TOSCA-compliant resources");
Resource testbed = adapterABox.getModel().createResource("http://federation.av.tu-berlin.de/about#AV_Smart_Communication_Testbed");
this.adapterABox.addProperty(Omn_federation.partOfFederation, testbed);
}
示例11: updateInstances
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
public Model updateInstances(Model model) throws InvalidRequestException, ProcessingException {
Model updatedInstancesModel = null;
try{
updatedInstancesModel = super.updateInstances(model);
} catch(InstanceNotFoundException e){
LOGGER.log(Level.INFO, "No resource instances found, looking for topologies..");
}
ResIterator resourceInstanceIterator = model.listSubjectsWithProperty(RDF.type, Omn.Topology);
while(resourceInstanceIterator.hasNext()){
Resource resourceInstance = resourceInstanceIterator.next();
LOGGER.log(Level.INFO, "Updating adapterABox: " + resourceInstance);
Model updatedModel = updateInstance(resourceInstance.getURI(), model);
updatedInstancesModel.add(updatedModel);
}
return updatedInstancesModel;
}
示例12: deleteInstances
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
@Override
public Model deleteInstances(Model model) throws InvalidRequestException, ProcessingException {
Model deletedInstancesModel = ModelFactory.createDefaultModel();
ResIterator resourceInstanceIterator = model.listSubjectsWithProperty(RDF.type, Omn.Topology);
while(resourceInstanceIterator.hasNext()){
String instanceURI = resourceInstanceIterator.next().getURI();
LOGGER.log(Level.INFO, "Deleting adapterABox: " + instanceURI);
deleteInstance(instanceURI);
Resource deletedInstance = deletedInstancesModel.createResource(instanceURI);
deletedInstance.addProperty(Omn_lifecycle.hasState, Omn_lifecycle.Removing);
}
return deletedInstancesModel;
}
示例13: removeAllLinguisticActs
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
/**
* This method remove all the linguistic acts having the input EARMARK item as information entity.
* @param item the item to consider.
* @return All the RDF statements removed from the model.
*/
protected Set<Statement> removeAllLinguisticActs(EARMARKItem item) {
Set<Statement> result = new HashSet<Statement>();
String base = "http://www.ontologydesignpatterns.org/cp/owl/semiotics.owl#";
Property hasInformationEntity = rdf.createProperty(base + "hasInformationEntity");
ResIterator linguisticActs = rdf.listSubjectsWithProperty(
hasInformationEntity, rdf.createResource(item.hasId().toString()));
while (linguisticActs.hasNext()) {
result.addAll(removeLinguisticAct(item, linguisticActs.next()));
}
return result;
}
示例14: indexSKOSModel
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
/**
* Creates the synonym index
*
* @throws IOException
*/
private void indexSKOSModel() throws IOException {
IndexWriterConfig cfg = new IndexWriterConfig(matchVersion, analyzer);
IndexWriter writer = new IndexWriter(indexDir, cfg);
writer.getConfig().setRAMBufferSizeMB(48);
/* iterate SKOS concepts, create Lucene docs and add them to the index */
ResIterator concept_iter = skosModel.listResourcesWithProperty(RDF.type,
SKOS.Concept);
while (concept_iter.hasNext()) {
Resource skos_concept = concept_iter.next();
Document concept_doc = createDocumentsFromConcept(skos_concept);
if (concept_doc != null) {
writer.addDocument(concept_doc);
}
}
writer.close();
}
示例15: listResourcesWith
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
public Set<Resource> listResourcesWith(Property... properties) {
Set<Resource> result = new HashSet<Resource>();
for (Property property: properties) {
ResIterator it = model.listResourcesWithProperty(property);
while (it.hasNext()) {
result.add(it.next());
}
}
return result;
}