/// <summary> /// Checks if the skos:hiddenLabel/skosxl:hiddenLabel informations can be added to the given concept /// </summary> internal static Boolean CheckHiddenLabel(RDFSKOSConceptScheme conceptScheme, RDFOntologyFact concept, RDFOntologyLiteral literal) { var canAddHiddenLabelInfo = false; //Pairwise disjointness with skos:prefLabel/skosxl:prefLabel must be preserved canAddHiddenLabelInfo = !(conceptScheme.Annotations.PrefLabel.SelectEntriesBySubject(concept) .Any(x => x.TaxonomyObject.Equals(literal))); if (canAddHiddenLabelInfo) { canAddHiddenLabelInfo = !(conceptScheme.Relations.PrefLabel.SelectEntriesBySubject(concept) .Any(x => conceptScheme.Relations.LiteralForm.SelectEntriesBySubject(x.TaxonomyObject) .Any(y => y.TaxonomyObject.Equals(literal)))); } //Pairwise disjointness with skos:altLabel/skosxl:altLabel must be preserved if (canAddHiddenLabelInfo) { canAddHiddenLabelInfo = !(conceptScheme.Annotations.AltLabel.SelectEntriesBySubject(concept) .Any(x => x.TaxonomyObject.Equals(literal))); } if (canAddHiddenLabelInfo) { canAddHiddenLabelInfo = !(conceptScheme.Relations.AltLabel.SelectEntriesBySubject(concept) .Any(x => conceptScheme.Relations.LiteralForm.SelectEntriesBySubject(x.TaxonomyObject) .Any(y => y.TaxonomyObject.Equals(literal)))); } return(canAddHiddenLabelInfo); }
public void AddNewRoom(string id, string typeRoom) { var newSemanticRoom = new RDFOntologyFact(GetClassResource(id)); ontology.Data.AddFact(newSemanticRoom); ontology.Data.AddClassTypeRelation(newSemanticRoom, new RDFOntologyClass(GetClassResource(typeRoom))); ontology.Data.AddAssertionRelation(newSemanticRoom, new RDFOntologyObjectProperty(GetResource("recordedIn")), raidFact); ontology.Data.AddAssertionRelation(newSemanticRoom, new RDFOntologyObjectProperty(GetResource("isPartOf")), houseFact); }
/// <summary> /// Gets an ontology data representation of this collection /// </summary> public RDFOntologyData ToRDFOntologyData() { var result = new RDFOntologyData(); //OrderedCollection result.AddFact(this); result.AddClassTypeRelation(this, RDFVocabulary.SKOS.ORDERED_COLLECTION.ToRDFOntologyClass()); result.AddAssertionRelation(this, RDFVocabulary.SKOS.MEMBER_LIST.ToRDFOntologyObjectProperty(), this.Representative); //Representative result.AddFact(this.Representative); //Concepts var reifSubj = new RDFOntologyFact((RDFResource)this.Representative.Value); if (this.ConceptsCount == 0) { result.Relations.ClassType.AddEntry(new RDFOntologyTaxonomyEntry(reifSubj, RDFVocabulary.RDF.TYPE.ToRDFOntologyObjectProperty(), RDFVocabulary.RDF.LIST.ToRDFOntologyClass())); result.Relations.Assertions.AddEntry(new RDFOntologyTaxonomyEntry(reifSubj, RDFVocabulary.RDF.FIRST.ToRDFOntologyObjectProperty(), RDFVocabulary.RDF.NIL.ToRDFOntologyFact())); result.Relations.Assertions.AddEntry(new RDFOntologyTaxonomyEntry(reifSubj, RDFVocabulary.RDF.REST.ToRDFOntologyObjectProperty(), RDFVocabulary.RDF.NIL.ToRDFOntologyFact())); } else { var itemCounter = 0; var conceptsEnum = this.ConceptsEnumerator; while (conceptsEnum.MoveNext()) { result.AddFact(conceptsEnum.Current.Item2); result.AddClassTypeRelation(conceptsEnum.Current.Item2, RDFVocabulary.SKOS.CONCEPT.ToRDFOntologyClass()); //first result.Relations.ClassType.AddEntry(new RDFOntologyTaxonomyEntry(reifSubj, RDFVocabulary.RDF.TYPE.ToRDFOntologyObjectProperty(), RDFVocabulary.RDF.LIST.ToRDFOntologyClass())); result.Relations.Assertions.AddEntry(new RDFOntologyTaxonomyEntry(reifSubj, RDFVocabulary.RDF.FIRST.ToRDFOntologyObjectProperty(), conceptsEnum.Current.Item2)); //rest itemCounter++; if (itemCounter < this.ConceptsCount) { var newReifSubj = new RDFOntologyFact(new RDFResource()); result.Relations.Assertions.AddEntry(new RDFOntologyTaxonomyEntry(reifSubj, RDFVocabulary.RDF.REST.ToRDFOntologyObjectProperty(), newReifSubj)); reifSubj = newReifSubj; } else { result.Relations.Assertions.AddEntry(new RDFOntologyTaxonomyEntry(reifSubj, RDFVocabulary.RDF.REST.ToRDFOntologyObjectProperty(), RDFVocabulary.RDF.NIL.ToRDFOntologyFact())); } } } return(result); }
public void UpdateObject(SemanticObject oldObj, SemanticObject newObj) { var objectFact = new RDFOntologyFact(GetClassResource(oldObj.Id)); //Update pose ontology.Data.RemoveAssertionRelation(objectFact, new RDFOntologyDatatypeProperty(GetResource("position")), new RDFOntologyLiteral(new RDFPlainLiteral(oldObj.Position.ToString()))); ontology.Data.AddAssertionRelation(objectFact, new RDFOntologyDatatypeProperty(GetResource("position")), new RDFOntologyLiteral(new RDFPlainLiteral(newObj.Position.ToString()))); //Update rotation ontology.Data.RemoveAssertionRelation(objectFact, new RDFOntologyDatatypeProperty(GetResource("rotation")), new RDFOntologyLiteral(new RDFPlainLiteral(oldObj.Rotation.eulerAngles.ToString()))); ontology.Data.AddAssertionRelation(objectFact, new RDFOntologyDatatypeProperty(GetResource("rotation")), new RDFOntologyLiteral(new RDFPlainLiteral(newObj.Rotation.eulerAngles.ToString()))); //Update size ontology.Data.RemoveAssertionRelation(objectFact, new RDFOntologyDatatypeProperty(GetResource("size")), new RDFOntologyLiteral(new RDFPlainLiteral(oldObj.Size.ToString()))); ontology.Data.AddAssertionRelation(objectFact, new RDFOntologyDatatypeProperty(GetResource("size")), new RDFOntologyLiteral(new RDFPlainLiteral(newObj.Size.ToString()))); //Update type ontology.Data.RemoveClassTypeRelation(objectFact, new RDFOntologyClass(GetClassResource(oldObj.ObjectClass))); ontology.Data.AddClassTypeRelation(objectFact, new RDFOntologyClass(GetClassResource(newObj.ObjectClass))); //Update score ontology.Data.RemoveAssertionRelation(objectFact, new RDFOntologyDatatypeProperty(GetResource("score")), new RDFOntologyLiteral(new RDFPlainLiteral(oldObj.Score.ToString()))); ontology.Data.AddAssertionRelation(objectFact, new RDFOntologyDatatypeProperty(GetResource("score")), new RDFOntologyLiteral(new RDFPlainLiteral(newObj.Score.ToString()))); //Update nDetections ontology.Data.RemoveAssertionRelation(objectFact, new RDFOntologyDatatypeProperty(GetResource("nDetections")), new RDFOntologyLiteral(new RDFPlainLiteral(oldObj.NDetections.ToString()))); ontology.Data.AddAssertionRelation(objectFact, new RDFOntologyDatatypeProperty(GetResource("nDetections")), new RDFOntologyLiteral(new RDFPlainLiteral(newObj.NDetections.ToString()))); }
public void LoadOntology() { // CREATE NAMESPACE nameSpace = new RDFNamespace(prefix, masterURI); raidID = GetNewTimeID(); var time = Time.realtimeSinceStartup; ontology = RDFOntology.FromRDFGraph(RDFSharp.Model.RDFGraph.FromFile(RDFModelEnums.RDFFormats.RdfXml, path)); raidFact = new RDFOntologyFact(GetClassResource(raidID)); ontology.Data.AddFact(raidFact); ontology.Data.AddClassTypeRelation(raidFact, new RDFOntologyClass(GetClassResource("Raid"))); UpdateListOfObjectsClassInOntology(); GetProbabilityRoomByClass(); cateogiesOfRooms = GetCategoriesOfRooms(); Log("Ontology loading time: " + (Time.realtimeSinceStartup - time).ToString(), LogLevel.Developer); }
public SemanticObject AddNewDetectedObject(SemanticObject obj) { if (obj.Id.Equals("")) { string id = GetNewTimeID() + "_" + obj.ObjectClass; obj.SetId(id); } var newDetectedObject = new RDFOntologyFact(GetClassResource(obj.Id)); ontology.Data.AddFact(newDetectedObject); ontology.Data.AddClassTypeRelation(newDetectedObject, new RDFOntologyClass(GetClassResource(obj.ObjectClass))); ontology.Data.AddAssertionRelation(newDetectedObject, new RDFOntologyDatatypeProperty(GetResource("position")), new RDFOntologyLiteral(new RDFPlainLiteral(obj.Position.ToString()))); ontology.Data.AddAssertionRelation(newDetectedObject, new RDFOntologyDatatypeProperty(GetResource("rotation")), new RDFOntologyLiteral(new RDFPlainLiteral(obj.Rotation.eulerAngles.ToString()))); ontology.Data.AddAssertionRelation(newDetectedObject, new RDFOntologyDatatypeProperty(GetResource("score")), new RDFOntologyLiteral(new RDFPlainLiteral(obj.Score.ToString()))); ontology.Data.AddAssertionRelation(newDetectedObject, new RDFOntologyDatatypeProperty(GetResource("nDetections")), new RDFOntologyLiteral(new RDFPlainLiteral(obj.NDetections.ToString()))); ontology.Data.AddAssertionRelation(newDetectedObject, new RDFOntologyDatatypeProperty(GetResource("size")), new RDFOntologyLiteral(new RDFPlainLiteral(obj.Size.ToString()))); ontology.Data.AddAssertionRelation(newDetectedObject, new RDFOntologyObjectProperty(GetResource("recordedIn")), raidFact); return(obj); }
/// <summary> /// Default-ctor to build a skos:OrderedCollection with the given name /// </summary> public RDFSKOSOrderedCollection(RDFResource collectionName) : base(collectionName) { this.ConceptsSequentialCounter = 0; this.Concepts = new Dictionary <Int64, Tuple <Int32, RDFSKOSConcept> >(); this.Representative = new RDFOntologyFact(new RDFResource("bnode:" + this.PatternMemberID)); }
/// <summary> /// Checks if the given "aFact -> datatypeProperty -> ontologyLiteral" can be a negative assertion /// </summary> internal static bool CheckNegativeAssertionCompatibility(RDFOntologyData ontologyData, RDFOntologyFact aFact, RDFOntologyDatatypeProperty datatypeProperty, RDFOntologyLiteral ontologyLiteral) => !ontologyData.CheckIsAssertion(aFact, datatypeProperty, ontologyLiteral);
/// <summary> /// Checks if the given "aFact -> objectProperty -> bFact" can be a negative assertion /// </summary> internal static bool CheckNegativeAssertionCompatibility(RDFOntologyData ontologyData, RDFOntologyFact aFact, RDFOntologyObjectProperty objProperty, RDFOntologyFact bFact) => !ontologyData.CheckIsAssertion(aFact, objProperty, bFact);
/// <summary> /// Checks if the given "aFact -> objectProperty -> bFact" has transitive assertions /// which would cause transitive cycles (unallowed concept in OWL-DL) /// </summary> internal static bool CheckTransitiveAssertionCompatibility(RDFOntologyData ontologyData, RDFOntologyFact aFact, RDFOntologyObjectProperty objProperty, RDFOntologyFact bFact) => !ontologyData.CheckIsTransitiveAssertionOf(bFact, objProperty, aFact);
/// <summary> /// Checks if the given afact can be set differentfrom the given bfact /// </summary> internal static bool CheckDifferentFromCompatibility(RDFOntologyData ontologyData, RDFOntologyFact aFact, RDFOntologyFact bFact) => !ontologyData.CheckIsSameFactAs(aFact, bFact);
/// <summary> /// Checks if the given afact can be set sameas the given bfact /// </summary> internal static bool CheckSameAsCompatibility(RDFOntologyData ontologyData, RDFOntologyFact aFact, RDFOntologyFact bFact) => !ontologyData.CheckIsDifferentFactFrom(aFact, bFact);
/// <summary> /// Checks if the skos:prefLabel/skosxl:prefLabel informations can be added to the given concept /// </summary> internal static Boolean CheckPrefLabel(RDFSKOSConceptScheme conceptScheme, RDFOntologyFact concept, RDFOntologyLiteral literal) { var canAddPrefLabelInfo = false; var prefLabelLiteralLang = ((RDFPlainLiteral)literal.Value).Language; //Plain literal without language tag: only one occurrence of this information is allowed if (String.IsNullOrEmpty(prefLabelLiteralLang)) { //Check skos:prefLabel annotation canAddPrefLabelInfo = !(conceptScheme.Annotations.PrefLabel.SelectEntriesBySubject(concept) .Any(x => x.TaxonomyObject.Value is RDFPlainLiteral && String.IsNullOrEmpty(((RDFPlainLiteral)x.TaxonomyObject.Value).Language))); //Check skosxl:prefLabel relation if (canAddPrefLabelInfo) { canAddPrefLabelInfo = !(conceptScheme.Relations.PrefLabel.SelectEntriesBySubject(concept) .Any(x => conceptScheme.Relations.LiteralForm.SelectEntriesBySubject(x.TaxonomyObject) .Any(y => y.TaxonomyObject.Value is RDFPlainLiteral && String.IsNullOrEmpty(((RDFPlainLiteral)y.TaxonomyObject.Value).Language)))); } } //Plain literal with language tag: only one occurrence of this information per language tag is allowed else { //Check skos:prefLabel annotation canAddPrefLabelInfo = !(conceptScheme.Annotations.PrefLabel.SelectEntriesBySubject(concept) .Any(x => x.TaxonomyObject.Value is RDFPlainLiteral && !String.IsNullOrEmpty(((RDFPlainLiteral)x.TaxonomyObject.Value).Language) && (((RDFPlainLiteral)x.TaxonomyObject.Value).Language).Equals(prefLabelLiteralLang, StringComparison.OrdinalIgnoreCase))); //Check skosxl:prefLabel relation if (canAddPrefLabelInfo) { canAddPrefLabelInfo = !(conceptScheme.Relations.PrefLabel.SelectEntriesBySubject(concept) .Any(x => conceptScheme.Relations.LiteralForm.SelectEntriesBySubject(x.TaxonomyObject) .Any(y => y.TaxonomyObject.Value is RDFPlainLiteral && !String.IsNullOrEmpty(((RDFPlainLiteral)x.TaxonomyObject.Value).Language) && (((RDFPlainLiteral)x.TaxonomyObject.Value).Language).Equals(prefLabelLiteralLang, StringComparison.OrdinalIgnoreCase)))); } } //Pairwise disjointness with skos:altLabel/skosxl:altLabel must be preserved if (canAddPrefLabelInfo) { //Check skos:altLabel annotation canAddPrefLabelInfo = !(conceptScheme.Annotations.AltLabel.SelectEntriesBySubject(concept) .Any(x => x.TaxonomyObject.Equals(literal))); //Check skosxl:altLabel relation if (canAddPrefLabelInfo) { canAddPrefLabelInfo = !(conceptScheme.Relations.AltLabel.SelectEntriesBySubject(concept) .Any(x => conceptScheme.Relations.LiteralForm.SelectEntriesBySubject(x.TaxonomyObject) .Any(y => y.TaxonomyObject.Equals(literal)))); } } //Pairwise disjointness with skos:hiddenLabel/skosxl:hiddenLabel must be preserved if (canAddPrefLabelInfo) { //Check skos:hiddenLabel annotation canAddPrefLabelInfo = !(conceptScheme.Annotations.HiddenLabel.SelectEntriesBySubject(concept) .Any(x => x.TaxonomyObject.Equals(literal))); //Check skosxl:hiddenLabel assertion if (canAddPrefLabelInfo) { canAddPrefLabelInfo = !(conceptScheme.Relations.HiddenLabel.SelectEntriesBySubject(concept) .Any(x => conceptScheme.Relations.LiteralForm.SelectEntriesBySubject(x.TaxonomyObject) .Any(y => y.TaxonomyObject.Equals(literal)))); } } return(canAddPrefLabelInfo); }
/// <summary> /// Default-ctor to build a skos:OrderedCollection with the given name /// </summary> public RDFSKOSOrderedCollection(RDFResource collectionName) : base(collectionName) { this.ConceptsSequentialCounter = 0; this.Concepts = new Dictionary <long, Tuple <int, RDFSKOSConcept> >(); this.Representative = new RDFOntologyFact(new RDFResource(string.Concat("bnode:", this.PatternMemberID.ToString()))); }
public void ObjectInRoom(string objectId, string roomId) { var obj = new RDFOntologyFact(GetClassResource(objectId)); ontology.Data.AddAssertionRelation(obj, new RDFOntologyObjectProperty(GetResource("isIn")), new RDFOntologyFact(GetClassResource(roomId))); }
public void AddNewHouse(string name) { houseFact = new RDFOntologyFact(GetClassResource(name)); ontology.Data.AddClassTypeRelation(houseFact, new RDFOntologyClass(GetClassResource("House"))); ontology.Data.AddAssertionRelation(raidFact, new RDFOntologyObjectProperty(GetResource("recordedIn")), houseFact); }