<commit_before>﻿/*
   Copyright 2012-2015 <NAME>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

using System;
using System.Collections.Generic;
using RDFSharp.Model;
using RDFSharp.Store;
using RDFSharp.Query;

namespace RDFSharp.Semantics
{

    /// <summary>
    /// RDFOntology represents an ontology definition.
    /// </summary>
    public class RDFOntology: RDFOntologyResource {

        #region Properties
        /// <summary>
        /// Model (T-BOX) of the ontology
        /// </summary>
        public RDFOntologyModel Model { get; internal set; }

        /// <summary>
        /// Data (A-BOX) of the ontology
        /// </summary>
        public RDFOntologyData Data { get; internal set; }

        /// <summary>
        /// Annotations describing the ontology
        /// </summary>
        public RDFOntologyAnnotationsMetadata Annotations { get; internal set; }
        #endregion

        #region Ctors
        /// <summary>
        /// Default-ctor to build an empty ontology with the given name
        /// </summary>
        public RDFOntology(RDFResource ontologyName) {
            if (ontologyName        != null) {
                this.Value           = ontologyName;
                this.PatternMemberID = ontologyName.PatternMemberID;
                this.Model           = new RDFOntologyModel();
                this.Data            = new RDFOntologyData();
                this.Annotations     = new RDFOntologyAnnotationsMetadata();
                RDFSemanticsUtilities.InitializeOntology(this);
            }
            else {
                throw new RDFSemanticsException("Cannot create RDFOntology because given \"ontologyName\" parameter is null.");
            }
        }
        #endregion

        #region Methods

        #region Add
        /// <summary>
        /// Adds the "ontology -> owl:VersionInfo -> ontologyLiteral" annotation to the ontology
        /// </summary>
        public RDFOntology AddVersionInfoAnnotation(RDFOntologyLiteral ontologyLiteral) {
            if (ontologyLiteral != null) {
                this.Annotations.VersionInfo.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.VERSION_INFO, ontologyLiteral));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> rdfs:comment -> ontologyLiteral" annotation to the ontology
        /// </summary>
        public RDFOntology AddCommentAnnotation(RDFOntologyLiteral ontologyLiteral) {
            if (ontologyLiteral != null) {
                this.Annotations.Comment.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.COMMENT, ontologyLiteral));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> rdfs:label -> ontologyLiteral" annotation to the ontology
        /// </summary>
        public RDFOntology AddLabelAnnotation(RDFOntologyLiteral ontologyLiteral) {
            if (ontologyLiteral != null) {
                this.Annotations.Label.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.LABEL, ontologyLiteral));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> rdfs:seeAlso -> ontologyResource" annotation to the ontology
        /// </summary>
        public RDFOntology AddSeeAlsoAnnotation(RDFOntologyResource ontologyResource) {
            if (ontologyResource != null) {
                this.Annotations.SeeAlso.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.SEE_ALSO, ontologyResource));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> rdfs:isDefinedBy -> ontologyResource" annotation to the ontology
        /// </summary>
        public RDFOntology AddIsDefinedByAnnotation(RDFOntologyResource ontologyResource) {
            if (ontologyResource != null) {
                this.Annotations.IsDefinedBy.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.IS_DEFINED_BY, ontologyResource));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> owl:priorVersion -> ontology" annotation to the ontology
        /// </summary>
        public RDFOntology AddPriorVersionAnnotation(RDFOntology ontology) {
            if (ontology != null) {
                this.Annotations.PriorVersion.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.PRIOR_VERSION, ontology));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> owl:backwardCompatibleWith -> ontology" annotation to the ontology
        /// </summary>
        public RDFOntology AddBackwardCompatibleWithAnnotation(RDFOntology ontology) {
            if (ontology != null) {
                this.Annotations.BackwardCompatibleWith.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.BACKWARD_COMPATIBLE_WITH, ontology));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> owl:incompatibleWith -> ontology" annotation to the ontology
        /// </summary>
        public RDFOntology AddIncompatibleWithAnnotation(RDFOntology ontology) {
            if (ontology != null) {
                this.Annotations.IncompatibleWith.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.INCOMPATIBLE_WITH, ontology));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> owl:imports -> ontology" annotation to the ontology
        /// </summary>
        public RDFOntology AddImportsAnnotation(RDFOntology ontology) {
            if (ontology != null) {
                this.Annotations.Imports.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.IMPORTS, ontology));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> ontologyAnnotationProperty -> ontologyResource" annotation to the ontology
        /// </summary>
        public RDFOntology AddCustomAnnotation(RDFOntologyAnnotationProperty ontologyAnnotationProperty, RDFOntologyResource ontologyResource) {
            if (ontologyAnnotationProperty != null && ontologyResource != null) {
                this.Annotations.CustomAnnotations.AddEntry(new RDFOntologyTaxonomyEntry(this, ontologyAnnotationProperty, ontologyResource));
            }
            return this;
        }
        #endregion

        #region Remove
        /// <summary>
        /// Removes the "ontology -> owl:VersionInfo -> ontologyLiteral" annotation from the ontology
        /// </summary>
        public RDFOntology RemoveVersionInfoAnnotation(RDFOntologyLiteral ontologyLiteral) {
            if (ontologyLiteral != null) {
                this.Annotations.VersionInfo.RemoveEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.VERSION_INFO, ontologyLiteral));
            }
            return this;
        }

        /// <summary>
        /// Removes the "ontology -> rdfs:comment -> ontologyLiteral" annotation from the ontology
        /// </summary>
        public RDFOntology RemoveCommentAnnotation(RDFOntologyLiteral ontologyLiteral) {
            if (ontologyLiteral != null) {
                this.Annotations.Comment.RemoveEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.COMMENT, ontologyLiteral));
            }
            return this;
        }<commit_msg>(FIX) Standard RDFS/OWL annotation properties cannot be used in custom annotations;<commit_after>﻿/*
   Copyright 2012-2015 <NAME>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

using System;
using System.Collections.Generic;
using RDFSharp.Model;
using RDFSharp.Store;
using RDFSharp.Query;

namespace RDFSharp.Semantics
{

    /// <summary>
    /// RDFOntology represents an ontology definition.
    /// </summary>
    public class RDFOntology: RDFOntologyResource {

        #region Properties
        /// <summary>
        /// Model (T-BOX) of the ontology
        /// </summary>
        public RDFOntologyModel Model { get; internal set; }

        /// <summary>
        /// Data (A-BOX) of the ontology
        /// </summary>
        public RDFOntologyData Data { get; internal set; }

        /// <summary>
        /// Annotations describing the ontology
        /// </summary>
        public RDFOntologyAnnotationsMetadata Annotations { get; internal set; }
        #endregion

        #region Ctors
        /// <summary>
        /// Default-ctor to build an empty ontology with the given name
        /// </summary>
        public RDFOntology(RDFResource ontologyName) {
            if (ontologyName        != null) {
                this.Value           = ontologyName;
                this.PatternMemberID = ontologyName.PatternMemberID;
                this.Model           = new RDFOntologyModel();
                this.Data            = new RDFOntologyData();
                this.Annotations     = new RDFOntologyAnnotationsMetadata();
                RDFSemanticsUtilities.InitializeOntology(this);
            }
            else {
                throw new RDFSemanticsException("Cannot create RDFOntology because given \"ontologyName\" parameter is null.");
            }
        }
        #endregion

        #region Methods

        #region Add
        /// <summary>
        /// Adds the "ontology -> owl:VersionInfo -> ontologyLiteral" annotation to the ontology
        /// </summary>
        public RDFOntology AddVersionInfoAnnotation(RDFOntologyLiteral ontologyLiteral) {
            if (ontologyLiteral != null) {
                this.Annotations.VersionInfo.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.VERSION_INFO, ontologyLiteral));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> rdfs:comment -> ontologyLiteral" annotation to the ontology
        /// </summary>
        public RDFOntology AddCommentAnnotation(RDFOntologyLiteral ontologyLiteral) {
            if (ontologyLiteral != null) {
                this.Annotations.Comment.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.COMMENT, ontologyLiteral));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> rdfs:label -> ontologyLiteral" annotation to the ontology
        /// </summary>
        public RDFOntology AddLabelAnnotation(RDFOntologyLiteral ontologyLiteral) {
            if (ontologyLiteral != null) {
                this.Annotations.Label.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.LABEL, ontologyLiteral));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> rdfs:seeAlso -> ontologyResource" annotation to the ontology
        /// </summary>
        public RDFOntology AddSeeAlsoAnnotation(RDFOntologyResource ontologyResource) {
            if (ontologyResource != null) {
                this.Annotations.SeeAlso.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.SEE_ALSO, ontologyResource));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> rdfs:isDefinedBy -> ontologyResource" annotation to the ontology
        /// </summary>
        public RDFOntology AddIsDefinedByAnnotation(RDFOntologyResource ontologyResource) {
            if (ontologyResource != null) {
                this.Annotations.IsDefinedBy.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.IS_DEFINED_BY, ontologyResource));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> owl:priorVersion -> ontology" annotation to the ontology
        /// </summary>
        public RDFOntology AddPriorVersionAnnotation(RDFOntology ontology) {
            if (ontology != null) {
                this.Annotations.PriorVersion.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.PRIOR_VERSION, ontology));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> owl:backwardCompatibleWith -> ontology" annotation to the ontology
        /// </summary>
        public RDFOntology AddBackwardCompatibleWithAnnotation(RDFOntology ontology) {
            if (ontology != null) {
                this.Annotations.BackwardCompatibleWith.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.BACKWARD_COMPATIBLE_WITH, ontology));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> owl:incompatibleWith -> ontology" annotation to the ontology
        /// </summary>
        public RDFOntology AddIncompatibleWithAnnotation(RDFOntology ontology) {
            if (ontology != null) {
                this.Annotations.IncompatibleWith.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.INCOMPATIBLE_WITH, ontology));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> owl:imports -> ontology" annotation to the ontology
        /// </summary>
        public RDFOntology AddImportsAnnotation(RDFOntology ontology) {
            if (ontology != null) {
                this.Annotations.Imports.AddEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.IMPORTS, ontology));
            }
            return this;
        }

        /// <summary>
        /// Adds the "ontology -> ontologyAnnotationProperty -> ontologyResource" annotation to the ontology
        /// </summary>
        public RDFOntology AddCustomAnnotation(RDFOntologyAnnotationProperty ontologyAnnotationProperty, RDFOntologyResource ontologyResource) {
            if (ontologyAnnotationProperty != null && ontologyResource != null) {

                //Standard RDFS/OWL annotation properties cannot be used in custom annotations
                if (ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.VERSION_INFO)             ||
                    ontologyAnnotationProperty.Equals(RDFVocabulary.RDFS.COMMENT)                 ||
                    ontologyAnnotationProperty.Equals(RDFVocabulary.RDFS.LABEL)                   ||
                    ontologyAnnotationProperty.Equals(RDFVocabulary.RDFS.SEE_ALSO)                ||
                    ontologyAnnotationProperty.Equals(RDFVocabulary.RDFS.IS_DEFINED_BY)           ||
                    ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.IMPORTS)                  ||
                    ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.BACKWARD_COMPATIBLE_WITH) ||
                    ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.INCOMPATIBLE_WITH)        ||
                    ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.PRIOR_VERSION)) {
                    return this;
                }

                this.Annotations.CustomAnnotations.AddEntry(new RDFOntologyTaxonomyEntry(this, ontologyAnnotationProperty, ontologyResource));
            }
            return this;
        }
        #endregion

        #region Remove
        /// <summary>
        /// Removes the "ontology -> owl:VersionInfo -> ontologyLiteral" annotation from the ontology
        /// </summary>
        public RDFOntology RemoveVersionInfoAnnotation(RDFOntologyLiteral ontologyLiteral) {
            if (ontologyLiteral != null) {
                this.Annotations.VersionInfo.RemoveEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.VERSION_INFO, ontologyLiteral));
            }
            return this;
        }

        /// <summary>
        /// Removes the "ontology -> rdfs:comment -> ontologyLiteral" annotation from the ontology
        /// </summary>
        public RDFOntology RemoveCommentAnnotation(RDFOntologyLiteral ontologyLiteral) {
            if (ontologyLiteral != null) {
                this.Annotations.Comment.RemoveEntry(new RDFOntologyTaxonomyEntry(this, RDFOntologyVocabulary.AnnotationProperties.COMMENT, ontologyLiteral));
            }
            return this;
        }
{'fraction_non_alphanumeric': 0.08713811648930084, 'fraction_numerical': 0.0013731548232063166, 'mean_word_length': 2.221935483870968, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 121, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5916034', 'n_tokens_mistral': 4696, 'n_tokens_neox': 4420, 'n_words': 1018}