Tabnine Logo
ReasonerRegistry
Code IndexAdd Tabnine to your IDE (free)

How to use
ReasonerRegistry
in
org.apache.jena.reasoner

Best Java code snippets using org.apache.jena.reasoner.ReasonerRegistry (Showing top 20 results out of 315)

origin: edu.amherst.acdc/acrepo-services-pcdm

  private Set<String> getObjectsOfProperty(final Model model, final String subject, final String property) {
    final InfModel infModel = createInfModel(getOWLMicroReasoner(), createDefaultModel());
    infModel.add(model.listStatements());
    infModel.add(pcdmModel.listStatements());
    return asStream(infModel.listObjectsOfProperty(createResource(subject), createProperty(property)))
        .filter(RDFNode::isURIResource).map(RDFNode::asResource).map(Resource::getURI).collect(toSet());
  }
}
origin: apache/jena

public WebOntTestHarness() {
  testDefinitions = loadAllTestDefinitions();
  reasoner = ReasonerRegistry.getOWLReasoner();
  initResults();
}
origin: apache/jena

/**
 * Return a Model through which all the RDFS entailments
 * derivable from the given model are accessible. Some work is done
 * when the inferenced model is created but each query will also trigger some
 * additional inference work.
 *
 * @param model the Model containing both instance data and schema assertions to be inferenced over
 */
public static InfModel createRDFSModel(Model model) {
   Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
   InfGraph graph = reasoner.bind( model.getGraph() );
   return new InfModelImpl( graph );
}
origin: apache/jena

/**
  Answer a ReasonerFactory which delivers reasoners with the given
  URL <code>reasonerURL</code>. If there is no such reasoner, throw
  an <code>UnknownreasonerException</code>.
*/
public static ReasonerFactory getReasonerFactoryByURL( Resource root, Resource reasonerURL )
  {
  String url = reasonerURL.getURI();
  ReasonerFactory factory = ReasonerRegistry.theRegistry().getFactory( url );
  if (factory == null) throw new UnknownReasonerException( root, reasonerURL );
  return factory;
  }
}
origin: apache/jena

/**
 * Return a property Node which represents the direct version of a
 * transitively closed property. See <code>makeDirect(String)</code>;
 * this method makes a new Node with the direct respelling of
 * <code>node</code>s URI.
 */
public static Node makeDirect(Node node) {
  return NodeFactory.createURI( makeDirect( node.getURI() ) );
}
origin: apache/jena

/**
 * Test that a transitive reduction is complete.
 * Assumes test graph has no cycles (other than the trivial
 * identity ones). 
 */
public void doTestTransitiveReduction(Model model, Property dp) {
  InfModel im = ModelFactory.createInfModel(ReasonerRegistry.getTransitiveReasoner(), model);
  
  for (ResIterator i = im.listSubjects(); i.hasNext();) {
    Resource base = i.nextResource();
    
    List<RDFNode> directLinks = new ArrayList<>();
    for (NodeIterator j = im.listObjectsOfProperty(base, dp); j.hasNext(); ) {
      directLinks.add(j.next());
    }
    for (int n = 0; n < directLinks.size(); n++) {
      Resource d1 = (Resource)directLinks.get(n);
      for (int m = n+1; m < directLinks.size(); m++) {
        Resource d2 = (Resource)directLinks.get(m);
        
        if (im.contains(d1, dp, d2) && ! base.equals(d1) && !base.equals(d2)) {
          assertTrue("Triangle discovered in transitive reduction", false);
        }
      }
    }
  }
}

origin: apache/jena

/**
 * Constructor is hidden - go via theRegistry
 */
private ReasonerRegistry() {
  allDescriptions = ModelFactory.createDefaultModel();
  // Preload the known Jena reasoners
  register(TransitiveReasonerFactory.theInstance());
  register(RDFSRuleReasonerFactory.theInstance());
  register(OWLFBRuleReasonerFactory.theInstance());
  register(GenericRuleReasonerFactory.theInstance());
  register(OWLMicroReasonerFactory.theInstance());
  register(OWLMiniReasonerFactory.theInstance());
}
origin: apache/jena

/**
 * Return the single global instance of the registry
 */
public static ReasonerRegistry theRegistry() {
  if (theRegistry == null) {
    theRegistry = new ReasonerRegistry();
  }
  return theRegistry;
}
origin: apache/jena

/**
 * Create and return a new instance of the reasoner identified by
 * the given uri.
 * @param uri the uri of the reasoner to be created, expressed as a simple string
 * @param configuration an optional set of configuration information encoded in RDF this
 * parameter can be null if no configuration information is required.
 * @return a reaoner instance
 * @throws ReasonerException if there is not such reasoner or if there is
 * some problem during instantiation
 */
public Reasoner create(String uri, Resource configuration) throws ReasonerException {
  ReasonerFactory factory = getFactory(uri);
  if (factory != null) {
    return factory.create(configuration);
  } else {
    throw new ReasonerException("Attempted to instantiate an unknown reasoner: " + uri);
  }
}
origin: org.apache.jena/jena-core

/**
 * Return a property Node which represents the direct version of a
 * transitively closed property. See <code>makeDirect(String)</code>;
 * this method makes a new Node with the direct respelling of
 * <code>node</code>s URI.
 */
public static Node makeDirect(Node node) {
  return NodeFactory.createURI( makeDirect( node.getURI() ) );
}
origin: org.apache.jena/jena-core

/**
  Answer a ReasonerFactory which delivers reasoners with the given
  URL <code>reasonerURL</code>. If there is no such reasoner, throw
  an <code>UnknownreasonerException</code>.
*/
public static ReasonerFactory getReasonerFactoryByURL( Resource root, Resource reasonerURL )
  {
  String url = reasonerURL.getURI();
  ReasonerFactory factory = ReasonerRegistry.theRegistry().getFactory( url );
  if (factory == null) throw new UnknownReasonerException( root, reasonerURL );
  return factory;
  }
}
origin: org.apache.jena/jena-core

/**
 * Test that a transitive reduction is complete.
 * Assumes test graph has no cycles (other than the trivial
 * identity ones). 
 */
public void doTestTransitiveReduction(Model model, Property dp) {
  InfModel im = ModelFactory.createInfModel(ReasonerRegistry.getTransitiveReasoner(), model);
  
  for (ResIterator i = im.listSubjects(); i.hasNext();) {
    Resource base = i.nextResource();
    
    List<RDFNode> directLinks = new ArrayList<>();
    for (NodeIterator j = im.listObjectsOfProperty(base, dp); j.hasNext(); ) {
      directLinks.add(j.next());
    }
    for (int n = 0; n < directLinks.size(); n++) {
      Resource d1 = (Resource)directLinks.get(n);
      for (int m = n+1; m < directLinks.size(); m++) {
        Resource d2 = (Resource)directLinks.get(m);
        
        if (im.contains(d1, dp, d2) && ! base.equals(d1) && !base.equals(d2)) {
          assertTrue("Triangle discovered in transitive reduction", false);
        }
      }
    }
  }
}

origin: org.apache.jena/jena-core

/**
 * Constructor is hidden - go via theRegistry
 */
private ReasonerRegistry() {
  allDescriptions = ModelFactory.createDefaultModel();
  // Preload the known Jena reasoners
  register(TransitiveReasonerFactory.theInstance());
  register(RDFSRuleReasonerFactory.theInstance());
  register(OWLFBRuleReasonerFactory.theInstance());
  register(GenericRuleReasonerFactory.theInstance());
  register(OWLMicroReasonerFactory.theInstance());
  register(OWLMiniReasonerFactory.theInstance());
}
origin: org.apache.jena/jena-core

/**
 * Return the single global instance of the registry
 */
public static ReasonerRegistry theRegistry() {
  if (theRegistry == null) {
    theRegistry = new ReasonerRegistry();
  }
  return theRegistry;
}
origin: org.apache.jena/jena-core

/**
 * Create and return a new instance of the reasoner identified by
 * the given uri.
 * @param uri the uri of the reasoner to be created, expressed as a simple string
 * @param configuration an optional set of configuration information encoded in RDF this
 * parameter can be null if no configuration information is required.
 * @return a reaoner instance
 * @throws ReasonerException if there is not such reasoner or if there is
 * some problem during instantiation
 */
public Reasoner create(String uri, Resource configuration) throws ReasonerException {
  ReasonerFactory factory = getFactory(uri);
  if (factory != null) {
    return factory.create(configuration);
  } else {
    throw new ReasonerException("Attempted to instantiate an unknown reasoner: " + uri);
  }
}
origin: org.apache.jena/jena-core

public WebOntTestHarness() {
  testDefinitions = loadAllTestDefinitions();
  reasoner = ReasonerRegistry.getOWLReasoner();
  initResults();
}
origin: org.apache.jena/jena-core

/**
 * Return a Model through which all the RDFS entailments
 * derivable from the given model are accessible. Some work is done
 * when the inferenced model is created but each query will also trigger some
 * additional inference work.
 *
 * @param model the Model containing both instance data and schema assertions to be inferenced over
 */
public static InfModel createRDFSModel(Model model) {
   Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
   InfGraph graph = reasoner.bind( model.getGraph() );
   return new InfModelImpl( graph );
}
origin: apache/jena

/**
  compact call to ReasonerRegistry.makeDirect
*/
private static final Property makeDirect( Property type )
  { return ResourceFactory.createProperty( ReasonerRegistry.makeDirect( type.asNode().getURI() ) ); }
origin: edu.amherst.acdc/acrepo-services-ore

  private Set<String> getObjectsOfProperty(final Model model, final String subject, final String property) {
    final InfModel infModel = createInfModel(getOWLMicroReasoner(), createDefaultModel());
    infModel.add(model.listStatements());
    infModel.add(oreModel.listStatements());
    return asStream(infModel.listObjectsOfProperty(createResource(subject), createProperty(property)))
        .filter(RDFNode::isURIResource).map(RDFNode::asResource).map(Resource::getURI).collect(toSet());
  }
}
origin: apache/jena

/**
 * The reasoner contract for bind(data) is not quite precise. It allows for
 * reasoners which have state so that reusing the same reasoner on a second data
 * model might lead to interference. This in fact used to happen with the transitive
 * reasoner. This is a test to check that the transitive reasoner state reuse has been fixed at source.
 */
public void testTransitiveBindReuse() {
  Reasoner  r = ReasonerRegistry.getTransitiveReasoner();
  InfModel om1 = ModelFactory.createInfModel(r, ModelFactory.createDefaultModel());
  Resource c1 = om1.createResource(PrintUtil.egNS + "Class1");
  Resource c2 = om1.createResource(PrintUtil.egNS + "Class2");
  Resource c3 = om1.createResource(PrintUtil.egNS + "Class3");
  om1.add(c1, RDFS.subClassOf, c2);
  om1.add(c2, RDFS.subClassOf, c3);
  om1.prepare();
  assertFalse(om1.isEmpty());
  InfModel om2 = ModelFactory.createInfModel(r, ModelFactory.createDefaultModel());
  StmtIterator si = om2.listStatements();
  boolean ok = ! si.hasNext();
  si.close();
  assertTrue("Transitive reasoner state leak", ok);
}

org.apache.jena.reasonerReasonerRegistry

Javadoc

A global registry of known reasoner modules. Modules are identified by a URI and can have associated capability and descriptive information, in RDF. Currently the schema/ontology for such descriptions is mostly open. However, we do ensure that each reasoner URI at least has an associated rdf:type statement to indicate that it is a reasoner.

It is up to each reasoner or some associated configuration system to register it in this registry.

Most used methods

  • getOWLMicroReasoner
    Prebuilt standard configuration a micro-OWL reasoner. This just supports property axioms, and class
  • getOWLReasoner
    Prebuilt standard configuration for the default OWL reasoner. This configuration is hybrid forward/b
  • getRDFSReasoner
    Return a prebuilt standard configuration for the default RDFS reasoner
  • makeDirect
    Return a property Node which represents the direct version of a transitively closed property. See ma
  • <init>
    Constructor is hidden - go via theRegistry
  • getFactory
    Return the factory for the given reasoner.
  • getTransitiveReasoner
    Return a prebuilt standard configuration for the default subclass/subproperty transitive closure rea
  • register
    Register a Reasoner.
  • theRegistry
    Return the single global instance of the registry

Popular in Java

  • Creating JSON documents from java classes using gson
  • requestLocationUpdates (LocationManager)
  • getSystemService (Context)
  • runOnUiThread (Activity)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now