<commit_before>﻿/*
   Copyright 2012-2022 <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 RDFSharp.Model;

namespace RDFSharp.Semantics.Extensions.SKOS
{
    /// <summary>
    /// SKOS validator rule checking for consistency of skos:hasTopConcept relations
    /// </summary>
    internal class SKOSTopConceptRule
    {
        internal static OWLValidatorReport ExecuteRule(SKOSConceptScheme conceptScheme)
        {
            OWLValidatorReport validatorRuleReport = new OWLValidatorReport();

            //skos:hasTopConcept
            foreach (RDFTriple hasTopConceptRelation in conceptScheme.Ontology.Data.ABoxGraph[conceptScheme, RDFVocabulary.SKOS.HAS_TOP_CONCEPT, null, null])
            { 
                if (conceptScheme.GetBroaderConcepts((RDFResource)hasTopConceptRelation.Object).Count > 0)
                    validatorRuleReport.AddEvidence(new OWLValidatorEvidence(
                        OWLSemanticsEnums.OWLValidatorEvidenceCategory.Warning,
                        nameof(SKOSTopConceptRule),
                        $"Violation of 'skos:hasTopConcept' behavior on concept scheme '{conceptScheme}' for concept '{hasTopConceptRelation.Object}'",
                        "If you specify a 'skos:Concept' as root concept of a 'skos:ConceptScheme', this concept should not have any broader concepts int it"));
            }

            return validatorRuleReport;
        }
    }
}<commit_msg>Better warning message<commit_after>﻿/*
   Copyright 2012-2022 <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 RDFSharp.Model;

namespace RDFSharp.Semantics.Extensions.SKOS
{
    /// <summary>
    /// SKOS validator rule checking for consistency of skos:hasTopConcept relations
    /// </summary>
    internal class SKOSTopConceptRule
    {
        internal static OWLValidatorReport ExecuteRule(SKOSConceptScheme conceptScheme)
        {
            OWLValidatorReport validatorRuleReport = new OWLValidatorReport();

            //skos:hasTopConcept
            foreach (RDFTriple hasTopConceptRelation in conceptScheme.Ontology.Data.ABoxGraph[conceptScheme, RDFVocabulary.SKOS.HAS_TOP_CONCEPT, null, null])
            { 
                if (conceptScheme.GetBroaderConcepts((RDFResource)hasTopConceptRelation.Object).Count > 0)
                    validatorRuleReport.AddEvidence(new OWLValidatorEvidence(
                        OWLSemanticsEnums.OWLValidatorEvidenceCategory.Warning,
                        nameof(SKOSTopConceptRule),
                        $"Violation of 'skos:hasTopConcept' behavior on concept scheme '{conceptScheme}' for concept '{hasTopConceptRelation.Object}'",
                        "If you specify a 'skos:Concept' as top concept of a 'skos:ConceptScheme', this concept should not have any broader concepts"));
            }

            return validatorRuleReport;
        }
    }
}
{'fraction_non_alphanumeric': 0.06823468596536572, 'fraction_numerical': 0.006720082708710261, 'mean_word_length': 2.8354806739345886, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '534796', 'n_tokens_mistral': 1038, 'n_tokens_neox': 987, 'n_words': 318}