Package org.mindswap.pellet.jena

Examples of org.mindswap.pellet.jena.PelletInfGraph


    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
    model.setStrictMode( false );
    model.read( mindswappers );
   
    //get the PelletInfGraph object
    PelletInfGraph pelletJenaGraph = ( PelletInfGraph )model.getGraph();
   
    // perform initial consistency check
    long s = System.currentTimeMillis();
    boolean consistent = pelletJenaGraph.isConsistent();
    long e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );

    // perform ABox addition which results in a consistent KB
    Resource concept = model.getResource( mindswap + "GraduateStudent" );
    Individual individual = model.createIndividual( mindswappers + "JohnDoe", concept );

    // perform incremental consistency check
    s = System.currentTimeMillis();
    consistent = pelletJenaGraph.isConsistent();
    e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );

    // perform ABox addition which results in an inconsistent KB
    Property role = model.getProperty( foaf + "mbox" );
    individual = model.getIndividual( mindswappers + "Christian.Halaschek" );
    RDFNode mbox = model.getIndividual( "mailto:kolovski@cs.umd.edu" );
    individual.addProperty( role, mbox );

    // perform incremental consistency check
    s = System.currentTimeMillis();
    consistent = pelletJenaGraph.isConsistent();
    e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );
  }
View Full Code Here


    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
    model.setStrictMode( false );
    model.read( mindswappers );
   
    //get the PelletInfGraph object
    PelletInfGraph pelletJenaGraph = ( PelletInfGraph )model.getGraph();
   
    // perform initial consistency check
    long s = System.currentTimeMillis();
    boolean consistent = pelletJenaGraph.isConsistent();
    long e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );

    // perform ABox addition which results in a consistent KB
    Resource concept = model.getResource( mindswap + "GraduateStudent" );
    Individual individual = model.createIndividual( mindswappers + "JohnDoe", concept );

    // perform incremental consistency check
    s = System.currentTimeMillis();
    consistent = pelletJenaGraph.isConsistent();
    e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );

    // perform ABox addition which results in an inconsistent KB
    Property role = model.getProperty( foaf + "mbox" );
    individual = model.getIndividual( mindswappers + "Christian.Halaschek" );
    RDFNode mbox = model.getIndividual( "mailto:kolovski@cs.umd.edu" );
    individual.addProperty( role, mbox );

    // perform incremental consistency check
    s = System.currentTimeMillis();
    consistent = pelletJenaGraph.isConsistent();
    e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );
  }
View Full Code Here

  private ResultSet exec() {
    try {
      if( source.listNames().hasNext() )
        throw new UnsupportedQueryException( "Named graphs is not supported by Pellet" );

      PelletInfGraph pelletInfGraph = (PelletInfGraph) source.getDefaultModel().getGraph();
      KnowledgeBase kb = pelletInfGraph.getKB();

      pelletInfGraph.prepare();

      QueryParameters queryParameters = new QueryParameters( initialBinding );

      ARQParser parser = new ARQParser( handleVariableSPO );
      // The parser uses the query parameterization to resolve parameters
View Full Code Here

    OntModel reasoner = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
    reasoner.addSubModel(m1);
    reasoner.addSubModel(m2);
   
    PelletInfGraph pellet = (PelletInfGraph) reasoner.getGraph();
    pellet.prepare();
   
    assertEquals(Collections.emptySet(), pellet.getLoader().getUnpportedFeatures());
  }
View Full Code Here

  public void testEntailment(String entailmentFileURI, boolean positiveEntailment) {
    Model entailments = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
    entailments.read( entailmentFileURI, entailmentFileURI, fileType( entailmentFileURI ) );
   
    Graph entailmentsGraph = entailments.getGraph();
    PelletInfGraph pellet = (PelletInfGraph) model.getGraph();

    GraphLoader savedLoader = pellet.attachTemporaryGraph( entailmentsGraph );

    ExtendedIterator i = entailmentsGraph.find( Triple.ANY );
   
    while( i.hasNext() ) {
      Triple triple = (Triple) i.next();
      if( !pellet.entails( triple ) ) {
        assertFalse( "Entailment failed for " + triple, positiveEntailment );
        return;       
      }
    }

    pellet.detachTemporaryGraph( entailmentsGraph, savedLoader );
   
    assertTrue( "All axioms entailed in negative entailment test", positiveEntailment );
  }
View Full Code Here

  private ResultSet exec() {
    try {
      if (source.listNames().hasNext())
        throw new UnsupportedQueryException("Named graphs is not supported by Pellet");

      PelletInfGraph pelletInfGraph = (PelletInfGraph) source.getDefaultModel().getGraph();
      KnowledgeBase kb = pelletInfGraph.getKB();

      pelletInfGraph.prepare();

      QueryParameters queryParameters = new QueryParameters(initialBinding);

      ARQParser parser = new ARQParser(handleVariableSPO);
      // The parser uses the query parameterization to resolve parameters
View Full Code Here

  public QueryIterator build(QueryIterator input, ExecutionContext execCxt) {
    Graph graph = execCxt.getActiveGraph();
    if( !(graph instanceof PelletInfGraph) )
      throw new UnsupportedOperationException( "A Pellet-backed model is required" );

    PelletInfGraph pellet = (PelletInfGraph) graph;

    pellet.prepare();

    Query query = parsePattern( pellet );

    if( query != null ) {
      return new PelletQueryIterator( pellet, query, input, execCxt );
View Full Code Here

    OntModel reasoner = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
    reasoner.addSubModel(m1);
    reasoner.addSubModel(m2);
   
    PelletInfGraph pellet = (PelletInfGraph) reasoner.getGraph();
    pellet.prepare();
   
    assertEquals(Collections.emptySet(), pellet.getLoader().getUnpportedFeatures());
  }
View Full Code Here

    fixedSchemaSpec.setReasoner(PelletReasonerFactory.theInstance().create().bindFixedSchema(schema));
   
    // create a new model whihc will have the schema loaded automatically
    OntModel model = ModelFactory.createOntologyModel(fixedSchemaSpec);

    PelletInfGraph graph = (PelletInfGraph) model.getGraph();
   
    assertFalse(graph.isClassified());
    assertIteratorValues(model.listObjectsOfProperty(A, RDFS.subClassOf), B, C, OWL.Thing);   
    assertTrue(graph.isClassified());

    model.add(a, RDF.type, A);
   
    graph.prepare();
    assertTrue(graph.isClassified());
    assertTrue(model.contains(a, RDF.type, C));
    assertIteratorValues(model.listObjectsOfProperty(A, RDFS.subClassOf), B, C, OWL.Thing);   
    assertTrue(graph.isClassified());

    Model subModel = ModelFactory.createDefaultModel();
    subModel.add(b, RDF.type, B);
    model.addSubModel(subModel);

    graph.prepare();
    assertTrue(graph.isClassified());
    assertTrue(model.contains(a, RDF.type, C));
    assertTrue(model.contains(b, RDF.type, C));
    assertIteratorValues(model.listObjectsOfProperty(A, RDFS.subClassOf), B, C, OWL.Thing);   
    assertTrue(graph.isClassified());

    model.remove(a, RDF.type, A);

    graph.prepare();
    assertTrue(graph.isClassified());
    assertFalse(model.contains(a, RDF.type, C));
    assertTrue(model.contains(b, RDF.type, C));
    assertIteratorValues(model.listObjectsOfProperty(A, RDFS.subClassOf), B, C, OWL.Thing);   
    assertTrue(graph.isClassified());

    model.removeSubModel(subModel);

    graph.prepare();
    assertTrue(graph.isClassified());
    assertFalse(model.contains(a, RDF.type, C));
    assertFalse(model.contains(b, RDF.type, C));
    assertIteratorValues(model.listObjectsOfProperty(A, RDFS.subClassOf), B, C, OWL.Thing);   
    assertTrue(graph.isClassified());
  }
View Full Code Here

      if( dataset.listNames().hasNext() || query.isDescribeType() ) {
        engineType = QueryEngineType.MIXED;
      }
      else {
        // try parsing the query and see if there are any problems
        PelletInfGraph pelletInfGraph = (PelletInfGraph) graph;

        KnowledgeBase kb = pelletInfGraph.getKB();
        pelletInfGraph.prepare();

        ARQParser parser = new ARQParser();
        // The parser uses the query parameterization to resolve
        // parameters
        // (i.e. variables) in the query
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.jena.PelletInfGraph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.