Exemplo n.º 1
0
        /// <summary>
        /// Enlists the skos:exactMatch concepts of the given concept within the given scheme
        /// </summary>
        public static RDFSKOSConceptScheme GetExactMatchConceptsOf(this RDFSKOSConceptScheme conceptScheme,
                                                                   RDFSKOSConcept concept)
        {
            var result = new RDFSKOSConceptScheme((RDFResource)conceptScheme.Value);

            if (concept != null && conceptScheme != null)
            {
                result = conceptScheme.GetExactMatchConceptsOfInternal(concept, null)
                         .RemoveConcept(concept);                //Safety deletion
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Subsumes the "skos:exactMatch" taxonomy to discover direct and indirect exactmatches of the given concept
        /// </summary>
        internal static RDFSKOSConceptScheme GetExactMatchConceptsOfInternal(this RDFSKOSConceptScheme conceptScheme,
                                                                             RDFSKOSConcept concept,
                                                                             Dictionary <long, RDFSKOSConcept> visitContext)
        {
            var result = new RDFSKOSConceptScheme((RDFResource)conceptScheme.Value);

            #region visitContext
            if (visitContext == null)
            {
                visitContext = new Dictionary <long, RDFSKOSConcept>()
                {
                    { concept.PatternMemberID, concept }
                };
            }
            else
            {
                if (!visitContext.ContainsKey(concept.PatternMemberID))
                {
                    visitContext.Add(concept.PatternMemberID, concept);
                }
                else
                {
                    return(result);
                }
            }
            #endregion

            // Transitivity of "skos:exactMatch" taxonomy:
            //((A SKOS:EXACTMATCH B)  &&  (B SKOS:EXACTMATCH C))  =>  (A SKOS:EXACTMATCH C)
            foreach (var em in conceptScheme.Relations.ExactMatch.SelectEntriesBySubject(concept))
            {
                result.AddConcept((RDFSKOSConcept)em.TaxonomyObject);
                result = result.UnionWith(conceptScheme.GetExactMatchConceptsOfInternal((RDFSKOSConcept)em.TaxonomyObject, visitContext));
            }

            return(result);
        }