本文整理汇总了Java中com.hp.hpl.jena.rdf.model.InfModel类的典型用法代码示例。如果您正苦于以下问题:Java InfModel类的具体用法?Java InfModel怎么用?Java InfModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InfModel类属于com.hp.hpl.jena.rdf.model包,在下文中一共展示了InfModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inferClassRelations_OLD
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
@Deprecated
public static boolean inferClassRelations_OLD(Model classModel) {
InputStream is = AbstractNIFParser.class.getClassLoader()
.getResourceAsStream(TYPE_INFERENCE_RULES);
List<String> lines;
try {
lines = IOUtils.readLines(is);
} catch (IOException e) {
LOGGER.error("Couldn't load type inferencer rules from resource \""
+ TYPE_INFERENCE_RULES
+ "\". Working on the standard model.", e);
return false;
}
IOUtils.closeQuietly(is);
StringBuilder sb = new StringBuilder();
for (String line : lines) {
sb.append(line);
}
Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(sb
.toString()));
InfModel infModel = ModelFactory.createInfModel(reasoner, classModel);
classModel.add(infModel);
return true;
}
示例2: createInferencer
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
public static SimpleSubClassInferencer createInferencer(Model classModel) {
String resourceName = GerbilConfiguration.getInstance().getString(SUB_CLASS_INFERENCER_RULE_FILE_KEY);
if (resourceName == null) {
LOGGER.error("Couldn't load subclass inferencer rules resource name from properties. Returning null.");
return null;
}
InputStream is = RootConfig.class.getClassLoader().getResourceAsStream(resourceName);
List<String> lines;
try {
lines = IOUtils.readLines(is);
} catch (IOException e) {
LOGGER.error("Couldn't load subclass inferencer rules from resource \"" + resourceName
+ "\". Returning null.", e);
return null;
}
IOUtils.closeQuietly(is);
StringBuilder sb = new StringBuilder();
for (String line : lines) {
sb.append(line);
}
Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(sb.toString()));
InfModel inf = ModelFactory.createInfModel(reasoner, classModel);
SimpleSubClassInferencer inferencer = new SimpleSubClassInferencer(inf);
return inferencer;
}
示例3: validate
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
/**
* Validates the collected sample.
*
* @param resource the Job resource representation (i.e. the sample owner).
* @param exchange the current exchange.
*/
public void validate(final JobResource resource, final Exchange exchange) {
log.info(MessageCatalog._00055_VALIDATING, resource.getID());
resource.markAsValidated();
collectSample(resource.getID(), exchange.getIn().getBody(String.class));
final InfModel infmodel = ModelFactory.createInfModel(reasoner, samples.remove(resource.getID()));
final ValidityReport validity = infmodel.validate();
if (!validity.isClean()) {
log.info(MessageCatalog._00057_VALIDATION_KO, resource.getID());
for (final Iterator<ValidityReport.Report> iterator = validity.getReports(); iterator.hasNext(); ) {
final ValidityReport.Report report = iterator.next();
validationMessageRepository.save(new ValidationMessage(resource.getID(), report.getType(), report.getDescription()));
log.info(MessageCatalog._00058_VALIDATION_MSG, resource.getID(), report.getDescription(), report.getType());
}
resource.setRunning(false);
exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);
} else {
log.info(MessageCatalog._00056_VALIDATION_OK, resource.getID());
}
}
示例4: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex5-data.ttl");
Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel,
ReasonerVocabulary.RDFS_DEFAULT);
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://www.example.org/example#worksFor> ?z }" ;
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n----------\ndone" );
}
示例5: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
public static void main( String[] args )
{
Model schema = FileManager.get().loadModel("file:data/input/turtle/ex1-schema.ttl");
Model data = FileManager.get().loadModel("file:data/input/turtle/ex1-data.ttl");
InfModel infmodel = ModelFactory.createRDFSModel(schema, data);
ValidityReport validity = infmodel.validate();
if (validity.isValid()) {
System.out.println("\nOK");
} else {
System.out.println("\nConflicts");
for (Iterator i = validity.getReports(); i.hasNext(); ) {
ValidityReport.Report report = (ValidityReport.Report)i.next();
System.out.println(" - " + report);
}
}
System.out.println( "done" );
}
示例6: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex13-data.ttl");
Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel,
ReasonerVocabulary.RDFS_DEFAULT);
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://www.w3.org/2000/01/rdf-schema#label> ?z }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "done" );
}
示例7: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex12-data2.ttl");
Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel,
ReasonerVocabulary.RDFS_DEFAULT);
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x WHERE { ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.org/example#Investigator> }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n---------------\n" );
}
示例8: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex17-data2.ttl");
Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel,
ReasonerVocabulary.RDFS_DEFAULT);
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://cal.example.com/cal#nextDeparture> ?z }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "done" );
}
示例9: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex12-data.ttl");
Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel,
ReasonerVocabulary.RDFS_DEFAULT);
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x WHERE { ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.org/example#Analyst> }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n---------------\n" );
}
示例10: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex22-data.ttl");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://www.example.org/example#hasAncestor> ?z }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "done" );
}
示例11: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex30-data.ttl");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?facility ?location WHERE { ?p <http://www.example.org/example#manufactureLocation> ?location . ?p <http://mfg.example.org/mfg#facility> ?facility . }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n-------DONE--------\n" );
}
示例12: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex30-data.ttl");
Model sameAsData = FileManager.get().loadModel( "file:data/input/turtle/ex30-sameas.ttl" );
data.add( sameAsData );
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?facility ?location WHERE { ?p <http://www.example.org/example#manufactureLocation> ?location . ?p <http://mfg.example.org/mfg#facility> ?facility . }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n-------DONE--------\n" );
}
示例13: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex19-data.ttl");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://www.example.org/example#hasPossession> ?z }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "done" );
}
示例14: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex21-data.ttl");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://www.example.org/example#married> ?z }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n---------------\n" );
}
示例15: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex20-data.ttl");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
/* Do a SPARQL Query over the data in the model */
String queryString = "SELECT ?x ?z WHERE { ?x <http://www.w3.org/2000/01/rdf-schema#subclassOf> ?z }";
/* Now create and execute the query using a Query object */
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n---------------\n" );
}