/// <summary> /// Gets a graph representation of this taxonomy, exporting inferences according to the selected behavior /// </summary> internal RDFGraph ToRDFGraph(RDFSemanticsEnums.RDFOntologyInferenceExportBehavior infexpBehavior) { var result = new RDFGraph(); //Taxonomy entries foreach (var te in this) { //Do not export semantic inferences if (infexpBehavior == RDFSemanticsEnums.RDFOntologyInferenceExportBehavior.None) { if (te.InferenceType == RDFSemanticsEnums.RDFOntologyInferenceType.None) { result.AddTriple(te.ToRDFTriple()); } } //Export semantic inferences related only to ontology model else if (infexpBehavior == RDFSemanticsEnums.RDFOntologyInferenceExportBehavior.OnlyModel) { if (this.Category == RDFSemanticsEnums.RDFOntologyTaxonomyCategory.Model || this.Category == RDFSemanticsEnums.RDFOntologyTaxonomyCategory.Annotation) { result.AddTriple(te.ToRDFTriple()); } else { if (te.InferenceType == RDFSemanticsEnums.RDFOntologyInferenceType.None) { result.AddTriple(te.ToRDFTriple()); } } } //Export semantic inferences related only to ontology data else if (infexpBehavior == RDFSemanticsEnums.RDFOntologyInferenceExportBehavior.OnlyData) { if (this.Category == RDFSemanticsEnums.RDFOntologyTaxonomyCategory.Data || this.Category == RDFSemanticsEnums.RDFOntologyTaxonomyCategory.Annotation) { result.AddTriple(te.ToRDFTriple()); } else { if (te.InferenceType == RDFSemanticsEnums.RDFOntologyInferenceType.None) { result.AddTriple(te.ToRDFTriple()); } } } //Export semantic inferences related both to ontology model and data else { result.AddTriple(te.ToRDFTriple()); } } return(result); }
/// <summary> /// Applies the given SPARQL SELECT query to the given ontology (which is converted into /// a RDF graph including semantic inferences in respect of the given export behavior) /// </summary> public static RDFSelectQueryResult ApplyToOntology(this RDFSelectQuery selectQuery, RDFOntology ontology, RDFSemanticsEnums.RDFOntologyInferenceExportBehavior ontologyInferenceExportBehavior = RDFSemanticsEnums.RDFOntologyInferenceExportBehavior.ModelAndData) { var result = new RDFSelectQueryResult(); if (selectQuery != null) { if (ontology != null) { RDFSemanticsEvents.RaiseSemanticsInfo(String.Format("Ontology '{0}' is going to be converted into a graph on which the SPARQL SELECT query will be applied. Please, remember that if the ontology validation has raised warnings or errors, you may get unexpected query results due to inconsistent semantic inferences!", ontology.Value)); var ontGraph = ontology.ToRDFGraph(ontologyInferenceExportBehavior); return(selectQuery.ApplyToGraph(ontGraph)); } } return(result); }
/// <summary> /// Gets a graph representation of this ontology data, exporting inferences according to the selected behavior /// </summary> public RDFGraph ToRDFGraph(RDFSemanticsEnums.RDFOntologyInferenceExportBehavior infexpBehavior) { var result = new RDFGraph(); //Relations result = result.UnionWith(this.Relations.SameAs.ToRDFGraph(infexpBehavior)) .UnionWith(this.Relations.DifferentFrom.ToRDFGraph(infexpBehavior)) .UnionWith(this.Relations.ClassType.ToRDFGraph(infexpBehavior)) .UnionWith(this.Relations.Assertions.ToRDFGraph(infexpBehavior)); //Annotations result = result.UnionWith(this.Annotations.VersionInfo.ToRDFGraph(infexpBehavior)) .UnionWith(this.Annotations.Comment.ToRDFGraph(infexpBehavior)) .UnionWith(this.Annotations.Label.ToRDFGraph(infexpBehavior)) .UnionWith(this.Annotations.SeeAlso.ToRDFGraph(infexpBehavior)) .UnionWith(this.Annotations.IsDefinedBy.ToRDFGraph(infexpBehavior)) .UnionWith(this.Annotations.CustomAnnotations.ToRDFGraph(infexpBehavior)); return(result); }
/// <summary> /// Gets a graph representation of this ontology model, exporting inferences according to the selected behavior /// </summary> public RDFGraph ToRDFGraph(RDFSemanticsEnums.RDFOntologyInferenceExportBehavior infexpBehavior) { return(this.ClassModel.ToRDFGraph(infexpBehavior) .UnionWith(this.PropertyModel.ToRDFGraph(infexpBehavior))); }
/// <summary> /// Gets a graph representation of this collection, exporting inferences according to the selected behavior /// </summary> public RDFGraph ToRDFGraph(RDFSemanticsEnums.RDFOntologyInferenceExportBehavior infexpBehavior) => this.ToRDFOntologyData().ToRDFGraph(infexpBehavior);
/// <summary> /// Asynchronously gts a graph representation of this ontology model, exporting inferences according to the selected behavior /// </summary> public Task <RDFGraph> ToRDFGraphAsync(RDFSemanticsEnums.RDFOntologyInferenceExportBehavior infexpBehavior) => Task.Run(() => ToRDFGraph(infexpBehavior));
/// <summary> /// Gets a graph representation of this ontology, exporting inferences according to the selected behavior /// </summary> public RDFGraph ToRDFGraph(RDFSemanticsEnums.RDFOntologyInferenceExportBehavior infexpBehavior) { return(RDFSemanticsUtilities.ToRDFGraph(this, infexpBehavior)); }