Package com.hp.hpl.jena.rdf.model

Examples of com.hp.hpl.jena.rdf.model.InfModel


          + "\n" + SYM_RULE
      ;
      ruleReasoner = new GenericRuleReasoner(Rule.parseRules(rules));
    }
    log.debug("\n" +"RULES:\n" +rules);
    InfModel inf = ModelFactory.createInfModel(ruleReasoner, model);
    log.debug("\n" +JenaUtil2.getOntModelAsString(inf, "N3"));
    int noTotal = 0;
    for ( Statement stmt : inf.listStatements().toList() ) {
      log.debug("^^ " +stmt);
      noTotal++;
    }
    log.debug("Total: " +noTotal);
View Full Code Here


        Model configurationRuleReasoner = ModelFactory.createDefaultModel();
        com.hp.hpl.jena.rdf.model.Resource configuration = configurationRuleReasoner.createResource();
        configuration.addProperty(ReasonerVocabulary.PROPruleMode, "forward");
        configuration.addProperty(ReasonerVocabulary.PROPsetRDFSLevel, ReasonerVocabulary.RDFS_SIMPLE);
        Reasoner ruleReasoner = RDFSRuleReasonerFactory.theInstance().create(configuration);
        InfModel inf = ModelFactory.createInfModel(ruleReasoner, schemaModel, baseModel);
        inf.read(new ByteArrayInputStream(TURTLE_RDF.getBytes()), "", "TURTLE");
        return inf;
    }
View Full Code Here

           
            reasoner.setOWLTranslation(true);               // not needed in RDFS case
            reasoner.setTransitiveClosureCaching(true);
           
           
            InfModel infModel = ModelFactory.createInfModel(reasoner, model);
           
            infModel.prepare();
            infModel.getDeductionsModel().write(System.out);
            //String sparql = "select * where {?s a <http://www.mytravels.com/Itinerary/MovieCityMuseums> }";
            //String sparql = "select * where {?s a <http://www.mytravels.com/Itinerary/CityEventItinerary> }";
            String sparql = "select * where {?s a <http://www.mytravels.com/Itinerary/MadridItinerary> }";
            //String sparql = "select * where {?s a <http://linkedevents.org/ontology/cazzo> }";
            //String sparql = "select * where {?s a <http://www.mytravels.com/Itinerary/MovieCityItinerary> }";
View Full Code Here

     * Generic method to perform inferences
     */
    @Override
    public InfModel run(Model data) {
        log.debug(" run(Model data)");
        InfModel im = ModelFactory.createInfModel(this.reasoner, data);
        im.prepare();
        return im;
    }
View Full Code Here

        // We keep the original list to prune the data after, if necessary
        if(filtered){
            Set<Statement> original = new HashSet<Statement>();
            original.addAll(data.listStatements().toSet());
            log.debug(" original statements are: {}",original.size());
            InfModel i = run(data);
            Set<Statement> inferred = i.listStatements().toSet();
            log.debug(" inferred statements are: {}",inferred.size());
            return prune(original, inferred);
        }else{
            return run(data).listStatements().toSet();
        }
View Full Code Here

        // We keep the original list to prune the data after, if necessary
        if(filtered){
            Set<Statement> original = new HashSet<Statement>();
            original.addAll(data.listStatements().toSet());
            log.debug(" original statements are: {}",original.size());
            InfModel i = run(data, rules);
            Set<Statement> inferred = i.listStatements().toSet();
            log.debug(" inferred statements are: {}",inferred.size());
            return prune(original, inferred);
        }else{
            return run(data, rules).listStatements().toSet();
        }
View Full Code Here

    Model input = ModelFactory.createUnion(TestData.foaf, TestData.alexdma.getModel());
   
    // Am I a foaf:Agent?
    log.info("Instantiating the OWL reasoner");

    InfModel inferred = reasoningService.run(input);

    Statement isAgent = TestData.model
        .createStatement(TestData.alexdma, RDF.type, TestData.foaf_Agent);

//    log.info("Statements: {}",
//        TestUtils.printStatements(inferred, TestData.alexdma, RDF.type));
    log.info("Is any foaf:Person a foaf:Agent...? {}",
        inferred.contains(isAgent));
    assertTrue(inferred.contains(isAgent));

    // Reset resource to be clean for other tests
    TestData.alexdma.removeProperties();
  }
View Full Code Here

    // Can I be a foaf:Organization and a foaf:Person at the same time?
    log.info("Instantiating the OWL reasoner");

    // Run the reasoner
    InfModel inferred = reasoningService.run(input);
   
//    log.info("Statements: {}",
//        TestUtils.printStatements(inferred, TestData.alexdma, RDF.type));
    ValidityReport validity = inferred.validate();

    log.info(
        "Can I be a foaf:Organization and a foaf:Person at the same time...? {}",
        validity.isValid());
    assertTrue(!validity.isValid());
View Full Code Here

    // Setup input for the reasoner
    Model input = ModelFactory.createUnion(TestData.foaf,
        TestData.alexdma.getModel());

    // Is alexdma foaf:Agent?
    InfModel inferred = reasoningService.run(input);

    Statement isAgent = TestData.model.createStatement(TestData.alexdma,
        RDF.type, TestData.foaf_Agent);

//    log.info("Statements: {}",
//        TestUtils.printStatements(inferred, TestData.alexdma, RDF.type));
    log.info("Is any foaf:Person is also a foaf:Agent...(true)? {}",
        inferred.contains(isAgent));
    assertTrue(inferred.contains(isAgent));

    // Reset resource to be clean for other tests
    TestData.alexdma.removeProperties();
  }
View Full Code Here

    // Setup input for the reasoner
    Model input = ModelFactory.createUnion(TestData.foaf,
        TestData.alexdma.getModel());

    // Is enridaga a foaf:Person?
    InfModel inferred = reasoningService.run(input);

    Statement isPerson = TestData.model.createStatement(TestData.enridaga,
        RDF.type, TestData.foaf_Person);

//    log.info("Statements: {}", TestUtils.printStatements(inferred,
//        TestData.enridaga, RDF.type));
    log.info("Is any rdfs:range of foaf:knows a foaf:Person...(true)? {}",
        inferred.contains(isPerson));

    assertTrue(inferred.contains(isPerson));

    // Reset resource to be clean for other tests
    TestData.alexdma.removeProperties();
  }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.InfModel

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.