/// <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); }
/// <summary> /// Adds the given literal as 'skos:example' annotation of the given concept within the conceptScheme /// </summary> public static RDFSKOSConceptScheme AddExampleAnnotation(this RDFSKOSConceptScheme conceptScheme, RDFSKOSConcept concept, RDFOntologyLiteral literal) { if (conceptScheme != null && concept != null && literal != null) { //Add example annotation to the scheme conceptScheme.Annotations.Example.AddEntry(new RDFOntologyTaxonomyEntry(concept, RDFVocabulary.SKOS.EXAMPLE.ToRDFOntologyAnnotationProperty(), literal)); } return(conceptScheme); }
/// <summary> /// Adds the given literal as 'skos:definition' annotation of the given concept within the conceptScheme /// </summary> public static RDFSKOSConceptScheme AddDefinitionAnnotation(this RDFSKOSConceptScheme conceptScheme, RDFSKOSConcept concept, RDFOntologyLiteral literal) { if (conceptScheme != null && concept != null && literal != null) { //Add definition annotation to the scheme conceptScheme.Annotations.Definition.AddEntry(new RDFOntologyTaxonomyEntry(concept, RDFVocabulary.SKOS.DEFINITION.ToRDFOntologyAnnotationProperty(), literal)); } return(conceptScheme); }
/// <summary> /// Adds the given literal as 'skos:scopeNote' annotation of the given concept within the conceptScheme /// </summary> public static RDFSKOSConceptScheme AddScopeNoteAnnotation(this RDFSKOSConceptScheme conceptScheme, RDFSKOSConcept concept, RDFOntologyLiteral literal) { if (conceptScheme != null && concept != null && literal != null) { //Add scopeNote annotation to the scheme conceptScheme.Annotations.ScopeNote.AddEntry(new RDFOntologyTaxonomyEntry(concept, RDFVocabulary.SKOS.SCOPE_NOTE.ToRDFOntologyAnnotationProperty(), literal)); } return(conceptScheme); }
/// <summary> /// Adds the given literal form of the given label within the conceptScheme /// </summary> public static RDFSKOSConceptScheme AddLiteralFormAssertion(this RDFSKOSConceptScheme conceptScheme, RDFSKOSLabel label, RDFOntologyLiteral literal) { if (conceptScheme != null && label != null && literal != null) { //Add literalForm relation conceptScheme.Relations.LiteralForm.AddEntry(new RDFOntologyTaxonomyEntry(label, RDFVocabulary.SKOS.SKOSXL.LITERAL_FORM.ToRDFOntologyDatatypeProperty(), literal)); } return(conceptScheme); }
/// <summary> /// Adds the given notation to the given concept within the conceptScheme /// </summary> public static RDFSKOSConceptScheme AddNotationRelation(this RDFSKOSConceptScheme conceptScheme, RDFSKOSConcept concept, RDFOntologyLiteral notationLiteral) { if (conceptScheme != null && concept != null && notationLiteral != null) { //Add skos:Notation relation to the scheme conceptScheme.Relations.Notation.AddEntry(new RDFOntologyTaxonomyEntry(concept, RDFVocabulary.SKOS.NOTATION.ToRDFOntologyDatatypeProperty(), notationLiteral)); } return(conceptScheme); }
/// <summary> /// Adds the "concept -> skos:hiddenLabel -> hiddenLabelLiteral" annotation to the concept scheme /// </summary> public static RDFSKOSConceptScheme AddHiddenLabelAnnotation(this RDFSKOSConceptScheme conceptScheme, RDFSKOSConcept concept, RDFOntologyLiteral hiddenLabelLiteral) { if (conceptScheme != null && concept != null && hiddenLabelLiteral != null) { //Only plain literals are allowed as skos:hiddenLabel annotations if (hiddenLabelLiteral.Value is RDFPlainLiteral) { if (RDFSKOSChecker.CheckHiddenLabel(conceptScheme, concept, hiddenLabelLiteral)) { //Add hiddenLabel annotation conceptScheme.Annotations.HiddenLabel.AddEntry(new RDFOntologyTaxonomyEntry(concept, RDFVocabulary.SKOS.HIDDEN_LABEL.ToRDFOntologyAnnotationProperty(), hiddenLabelLiteral)); } } } return(conceptScheme); }
/// <summary> /// Adds the given literal as preferred label annotation of the given concept within the conceptScheme /// </summary> public static RDFSKOSConceptScheme AddPrefLabelAnnotation(this RDFSKOSConceptScheme conceptScheme, RDFSKOSConcept concept, RDFOntologyLiteral prefLabelLiteral) { if (conceptScheme != null && concept != null && prefLabelLiteral != null) { //Only plain literals are allowed as skos:prefLabel annotations if (prefLabelLiteral.Value is RDFPlainLiteral) { if (RDFSKOSChecker.CheckPrefLabel(conceptScheme, concept, prefLabelLiteral)) { //Add prefLabel annotation conceptScheme.Annotations.PrefLabel.AddEntry(new RDFOntologyTaxonomyEntry(concept, RDFVocabulary.SKOS.PREF_LABEL.ToRDFOntologyAnnotationProperty(), prefLabelLiteral)); } } } return(conceptScheme); }
/// <summary> /// Adds the given label as hidden label of the given concept within the conceptScheme /// </summary> public static RDFSKOSConceptScheme AddHiddenLabelRelation(this RDFSKOSConceptScheme conceptScheme, RDFSKOSConcept concept, RDFSKOSLabel label, RDFOntologyLiteral hiddenLabelLiteral) { if (conceptScheme != null && concept != null && label != null && hiddenLabelLiteral != null) { //Only plain literals are allowed as skosxl:hiddenLabel assertions if (hiddenLabelLiteral.Value is RDFPlainLiteral) { if (RDFSKOSChecker.CheckHiddenLabel(conceptScheme, concept, hiddenLabelLiteral)) { //Add hiddenLabel relation conceptScheme.Relations.HiddenLabel.AddEntry(new RDFOntologyTaxonomyEntry(concept, RDFVocabulary.SKOS.SKOSXL.HIDDEN_LABEL.ToRDFOntologyObjectProperty(), label)); //Add literalForm relation conceptScheme.Relations.LiteralForm.AddEntry(new RDFOntologyTaxonomyEntry(label, RDFVocabulary.SKOS.SKOSXL.LITERAL_FORM.ToRDFOntologyDatatypeProperty(), hiddenLabelLiteral)); } } } return(conceptScheme); }
/// <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 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); }