org.apache.jena.rdf.model.ResIterator.toList()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.apache.jena.rdf.model.ResIterator.toList方法的一些代码示例,展示了ResIterator.toList的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResIterator.toList方法的具体详情如下:
包路径:org.apache.jena.rdf.model.ResIterator
类名称:ResIterator
方法名:toList

ResIterator.toList介绍

暂无

代码示例

代码示例来源:origin: io.github.luzzu/luzzu-semantics

private static String guessNamespace(Model temp) {
  List<Resource> res = temp.listSubjectsWithProperty(RDF.type, OWL.Ontology).toList();
  Map<String, Integer> tempMap = new HashMap<String, Integer>();
  for (Resource r : res) {
    String ns = r.getNameSpace();
    tempMap.put(ns, (tempMap.containsKey(ns)) ? (tempMap.get(ns) + 1) : 1);
  }
  
  if (tempMap.size() > 0)
    return (String) sortByValue(tempMap).keySet().toArray()[0];
  else
    return null;
}

代码示例来源:origin: org.aksw.rdfunit/rdfunit-model

public Collection<TestGenerator> getTestGeneratorsFromModel(Model model) {
  return getTestGeneratorsFromResourceList(
      model.listResourcesWithProperty(RDF.type, RDFUNITv.TestGenerator).toList()
  );
}

代码示例来源:origin: AKSW/RDFUnit

public Collection<Pattern> getPatternsFromModel(Model model) {
  return getPatternsFromResourceList(
      model.listResourcesWithProperty(RDF.type, RDFUNITv.Pattern).toList()
  );
}

代码示例来源:origin: TopQuadrant/shacl

public static List<SHResult> getAllTopLevelResults(Model model) {
  List<SHResult> results = new LinkedList<SHResult>();
  for(Resource type : RESULT_TYPES) {
    for(Resource r : model.listResourcesWithProperty(RDF.type, type).toList()) {
      if(!model.contains(null, SH.detail, r)) {
        results.add(r.as(SHResult.class));
      }
    }
  }
  return results;
}

代码示例来源:origin: org.aksw.rdfunit/rdfunit-model

public Collection<Pattern> getPatternsFromModel(Model model) {
  return getPatternsFromResourceList(
      model.listResourcesWithProperty(RDF.type, RDFUNITv.Pattern).toList()
  );
}

代码示例来源:origin: ch.epfl.bluebrain.nexus.org.topbraid/shacl

public static List<SHResult> getAllTopLevelResults(Model model) {
  List<SHResult> results = new LinkedList<SHResult>();
  for(Resource type : RESULT_TYPES) {
    for(Resource r : model.listResourcesWithProperty(RDF.type, type).toList()) {
      if(!model.contains(null, SH.detail, r)) {
        results.add(r.as(SHResult.class));
      }
    }
  }
  return results;
}

代码示例来源:origin: AKSW/RDFUnit

public Collection<TestGenerator> getTestGeneratorsFromModel(Model model) {
  return getTestGeneratorsFromResourceList(
      model.listResourcesWithProperty(RDF.type, RDFUNITv.TestGenerator).toList()
  );
}

代码示例来源:origin: org.aksw.rdfunit/rdfunit-model

public Collection<TestCase> getTestCasesFromModel(Model model) {
  ConcurrentLinkedQueue<TestCase> testCases = new ConcurrentLinkedQueue<>();
  model.listResourcesWithProperty(RDF.type, RDFUNITv.ManualTestCase).toList()
      .parallelStream()
      .forEach(resource -> testCases.add(ManualTestCaseReader.create().read(resource)));
  model.listResourcesWithProperty(RDF.type, RDFUNITv.PatternBasedTestCase)
      .toList()
      .parallelStream()
      .forEach(resource -> {
        try {
          testCases.add(PatternBasedTestCaseReader.create().read(resource));
        } catch (IllegalArgumentException ex) {
          log.warn("Cannot create PatternBasedTestCase {}", resource.toString(), ex);
        }
      });
  return ImmutableList.copyOf(testCases);
}

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

public static List<Resource> loadTestSuitesSqcf(String baseFile) {
  Model testSuitesModel = RDFDataMgr.loadModel(baseFile, Lang.TURTLE);
  normalizeSqcfModel(testSuitesModel);
  List<Resource> result = testSuitesModel.listSubjectsWithProperty(SparqlQcVocab.hasTest).toList();
  //enrichTestCasesWithLabels(testSuitesModel);
  return result;
}

代码示例来源:origin: org.aksw.jena-sparql-api/jena-sparql-api-resources-sparqlqc

public static List<Resource> loadTestSuitesSqcf(String baseFile) {
  Model testSuitesModel = RDFDataMgr.loadModel(baseFile, Lang.TURTLE);
  normalizeSqcfModel(testSuitesModel);
  List<Resource> result = testSuitesModel.listSubjectsWithProperty(SparqlQcVocab.hasTest).toList();
  //enrichTestCasesWithLabels(testSuitesModel);
  return result;
}

代码示例来源:origin: org.aksw.jena-sparql-api/jena-sparql-api-resources-sparqlqc

public static List<Resource> loadTestSuites(Model testSuitesModel, String baseFile) throws IOException {
  List<Resource> result = testSuitesModel
      .listResourcesWithProperty(RDF.type, SparqlQcVocab.TestSuite).toList();
  for (Resource testSuite : result) {
    loadTestSuite(testSuite, baseFile);
  }
  enrichTestCasesWithLabels(testSuitesModel);
  return result;
}

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

public static List<Resource> loadTestSuites(Model testSuitesModel, String baseFile) throws IOException {
  List<Resource> result = testSuitesModel
      .listResourcesWithProperty(RDF.type, SparqlQcVocab.TestSuite).toList();
  for (Resource testSuite : result) {
    loadTestSuite(testSuite, baseFile);
  }
  enrichTestCasesWithLabels(testSuitesModel);
  return result;
}

代码示例来源:origin: TopQuadrant/shacl

public static boolean isCompatibleWith(Resource platform) {
  if(get().isCompatibleWithExactly(platform)) {
    return true;
  }
  // Warning: this does assume that no loops exist
  for(Resource include : platform.getModel().listSubjectsWithProperty(DASH.includedExecutionPlatform, platform).toList()) {
    if(isCompatibleWith(include)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: ch.epfl.bluebrain.nexus.org.topbraid/shacl

public static boolean isCompatibleWith(Resource platform) {
  if(get().isCompatibleWithExactly(platform)) {
    return true;
  }
  // Warning: this does assume that no loops exist
  for(Resource include : platform.getModel().listSubjectsWithProperty(DASH.includedExecutionPlatform, platform).toList()) {
    if(isCompatibleWith(include)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: ch.epfl.bluebrain.nexus.org.topbraid/shacl

public static void addDetails(Resource parentResult, Model nestedResults) {
    if(!nestedResults.isEmpty()) {
      parentResult.getModel().add(nestedResults);
      for(Resource type : SHACLUtil.RESULT_TYPES) {
        for(Resource nestedResult : nestedResults.listSubjectsWithProperty(RDF.type, type).toList()) {
          if(!parentResult.getModel().contains(null, SH.detail, nestedResult)) {
            parentResult.addProperty(SH.detail, nestedResult);
          }
        }
      }
    }
  }
}

代码示例来源:origin: apache/jena

public void testListSubjects()
{
  fill(model);
  final List<Resource> L = model.listSubjects().toList();
  Assert.assertEquals(TestObjects.numberSubjects, L.size());
  final Set<Resource> wanted = subjectSet(TestObjects.numberSubjects);
  Assert.assertEquals(wanted, GraphTestBase.iteratorToSet(L.iterator()));
}

代码示例来源:origin: TopQuadrant/shacl

public static void addDetails(Resource parentResult, Model nestedResults) {
    if(!nestedResults.isEmpty()) {
      parentResult.getModel().add(nestedResults);
      for(Resource type : SHACLUtil.RESULT_TYPES) {
        for(Resource nestedResult : nestedResults.listSubjectsWithProperty(RDF.type, type).toList()) {
          if(!parentResult.getModel().contains(null, SH.detail, nestedResult)) {
            parentResult.addProperty(SH.detail, nestedResult);
          }
        }
      }
    }
  }
}

代码示例来源:origin: org.apache.jena/jena-core

public void testListSubjects()
{
  fill(model);
  final List<Resource> L = model.listSubjects().toList();
  Assert.assertEquals(TestObjects.numberSubjects, L.size());
  final Set<Resource> wanted = subjectSet(TestObjects.numberSubjects);
  Assert.assertEquals(wanted, GraphTestBase.iteratorToSet(L.iterator()));
}

代码示例来源:origin: AKSW/RDFUnit

public static void main(String[] args) throws Exception {
  CommandLine commandLine = parseArguments(args);
  if (commandLine.hasOption("h")) {
    displayHelp();
    System.exit(0);
  }
  RdfReader input = getInputReader(commandLine);
  RdfWriter output = getOutputWriter(commandLine);
  Model model = ModelFactory.createDefaultModel();
  for (Resource testExecutionResource: input.read().listResourcesWithProperty(RDF.type, RDFUNITv.TestExecution).toList()) {
    TestExecution testExecution = TestExecutionReader.create().read(testExecutionResource);
    Collection<QualityMeasure> report = new DqvReport(testExecution, MetricMapper.createDefault()).getQualityMeasures();
    DqvReportWriter.create(report).write(model);
  }
  output.write(model);
}

代码示例来源:origin: Galigator/openllet

@Test
public void retrieveSubjectsOfBnode()
{
  final String NS = "urn:test:";
  final Resource s = ResourceFactory.createResource(NS + "s");
  final Property p = ResourceFactory.createProperty(NS + "p");
  final Property q = ResourceFactory.createProperty(NS + "q");
  final Resource o = ResourceFactory.createResource();
  final OntModel pelletModel = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
  pelletModel.add(q, RDFS.subPropertyOf, p);
  pelletModel.add(s, q, o);
  assertEquals(Collections.singletonList(s), pelletModel.listSubjectsWithProperty(p, o).toList());
}

相关文章