示例#1
0
        /// <summary>
        /// Builds a new intersection data from this data and a given one
        /// </summary>
        public RDFOntologyData IntersectWith(RDFOntologyData ontologyData)
        {
            var result = new RDFOntologyData();

            if (ontologyData != null)
            {
                //Add intersection facts
                foreach (var f in this)
                {
                    if (ontologyData.Facts.ContainsKey(f.PatternMemberID))
                    {
                        result.AddFact(f);
                    }
                }

                //Add intersection literals
                foreach (var l in this.Literals.Values)
                {
                    if (ontologyData.Literals.ContainsKey(l.PatternMemberID))
                    {
                        result.AddLiteral(l);
                    }
                }

                //Add intersection relations
                result.Relations.ClassType     = this.Relations.ClassType.IntersectWith(ontologyData.Relations.ClassType);
                result.Relations.SameAs        = this.Relations.SameAs.IntersectWith(ontologyData.Relations.SameAs);
                result.Relations.DifferentFrom = this.Relations.DifferentFrom.IntersectWith(ontologyData.Relations.DifferentFrom);
                result.Relations.Assertions    = this.Relations.Assertions.IntersectWith(ontologyData.Relations.Assertions);

                //Add intersection annotations
                result.Annotations.VersionInfo       = this.Annotations.VersionInfo.IntersectWith(ontologyData.Annotations.VersionInfo);
                result.Annotations.Comment           = this.Annotations.Comment.IntersectWith(ontologyData.Annotations.Comment);
                result.Annotations.Label             = this.Annotations.Label.IntersectWith(ontologyData.Annotations.Label);
                result.Annotations.SeeAlso           = this.Annotations.SeeAlso.IntersectWith(ontologyData.Annotations.SeeAlso);
                result.Annotations.IsDefinedBy       = this.Annotations.IsDefinedBy.IntersectWith(ontologyData.Annotations.IsDefinedBy);
                result.Annotations.CustomAnnotations = this.Annotations.CustomAnnotations.IntersectWith(ontologyData.Annotations.CustomAnnotations);
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// Builds a new difference data from this data and a given one
        /// </summary>
        public RDFOntologyData DifferenceWith(RDFOntologyData ontologyData)
        {
            var result = new RDFOntologyData();

            if (ontologyData != null)
            {
                //Add difference facts
                foreach (var f in this)
                {
                    if (!ontologyData.Facts.ContainsKey(f.PatternMemberID))
                    {
                        result.AddFact(f);
                    }
                }

                //Add difference literals
                foreach (var l in this.Literals.Values)
                {
                    if (!ontologyData.Literals.ContainsKey(l.PatternMemberID))
                    {
                        result.AddLiteral(l);
                    }
                }

                //Add difference relations
                result.Relations.ClassType     = this.Relations.ClassType.DifferenceWith(ontologyData.Relations.ClassType);
                result.Relations.SameAs        = this.Relations.SameAs.DifferenceWith(ontologyData.Relations.SameAs);
                result.Relations.DifferentFrom = this.Relations.DifferentFrom.DifferenceWith(ontologyData.Relations.DifferentFrom);
                result.Relations.Assertions    = this.Relations.Assertions.DifferenceWith(ontologyData.Relations.Assertions);

                //Add difference annotations
                result.Annotations.VersionInfo       = this.Annotations.VersionInfo.DifferenceWith(ontologyData.Annotations.VersionInfo);
                result.Annotations.Comment           = this.Annotations.Comment.DifferenceWith(ontologyData.Annotations.Comment);
                result.Annotations.Label             = this.Annotations.Label.DifferenceWith(ontologyData.Annotations.Label);
                result.Annotations.SeeAlso           = this.Annotations.SeeAlso.DifferenceWith(ontologyData.Annotations.SeeAlso);
                result.Annotations.IsDefinedBy       = this.Annotations.IsDefinedBy.DifferenceWith(ontologyData.Annotations.IsDefinedBy);
                result.Annotations.CustomAnnotations = this.Annotations.CustomAnnotations.DifferenceWith(ontologyData.Annotations.CustomAnnotations);
            }
            else
            {
                //Add facts from this data
                foreach (var f in this)
                {
                    result.AddFact(f);
                }

                //Add literals from this data
                foreach (var l in this.Literals.Values)
                {
                    result.AddLiteral(l);
                }

                //Add relations from this data
                result.Relations.ClassType     = result.Relations.ClassType.UnionWith(this.Relations.ClassType);
                result.Relations.SameAs        = result.Relations.SameAs.UnionWith(this.Relations.SameAs);
                result.Relations.DifferentFrom = result.Relations.DifferentFrom.UnionWith(this.Relations.DifferentFrom);
                result.Relations.Assertions    = result.Relations.Assertions.UnionWith(this.Relations.Assertions);

                //Add annotations from this data
                result.Annotations.VersionInfo       = result.Annotations.VersionInfo.UnionWith(this.Annotations.VersionInfo);
                result.Annotations.Comment           = result.Annotations.Comment.UnionWith(this.Annotations.Comment);
                result.Annotations.Label             = result.Annotations.Label.UnionWith(this.Annotations.Label);
                result.Annotations.SeeAlso           = result.Annotations.SeeAlso.UnionWith(this.Annotations.SeeAlso);
                result.Annotations.IsDefinedBy       = result.Annotations.IsDefinedBy.UnionWith(this.Annotations.IsDefinedBy);
                result.Annotations.CustomAnnotations = result.Annotations.CustomAnnotations.UnionWith(this.Annotations.CustomAnnotations);
            }
            return(result);
        }
示例#3
0
        /// <summary>
        /// Builds a new union data from this data and a given one
        /// </summary>
        public RDFOntologyData UnionWith(RDFOntologyData ontologyData)
        {
            var result = new RDFOntologyData();

            //Add facts from this data
            foreach (var f in this)
            {
                result.AddFact(f);
            }

            //Add literals from this data
            foreach (var l in this.Literals.Values)
            {
                result.AddLiteral(l);
            }

            //Add relations from this data
            result.Relations.ClassType     = result.Relations.ClassType.UnionWith(this.Relations.ClassType);
            result.Relations.SameAs        = result.Relations.SameAs.UnionWith(this.Relations.SameAs);
            result.Relations.DifferentFrom = result.Relations.DifferentFrom.UnionWith(this.Relations.DifferentFrom);
            result.Relations.Assertions    = result.Relations.Assertions.UnionWith(this.Relations.Assertions);

            //Add annotations from this data
            result.Annotations.VersionInfo       = result.Annotations.VersionInfo.UnionWith(this.Annotations.VersionInfo);
            result.Annotations.Comment           = result.Annotations.Comment.UnionWith(this.Annotations.Comment);
            result.Annotations.Label             = result.Annotations.Label.UnionWith(this.Annotations.Label);
            result.Annotations.SeeAlso           = result.Annotations.SeeAlso.UnionWith(this.Annotations.SeeAlso);
            result.Annotations.IsDefinedBy       = result.Annotations.IsDefinedBy.UnionWith(this.Annotations.IsDefinedBy);
            result.Annotations.CustomAnnotations = result.Annotations.CustomAnnotations.UnionWith(this.Annotations.CustomAnnotations);

            //Manage the given data
            if (ontologyData != null)
            {
                //Add facts from the given data
                foreach (var f in ontologyData)
                {
                    result.AddFact(f);
                }

                //Add literals from the given data
                foreach (var l in ontologyData.Literals.Values)
                {
                    result.AddLiteral(l);
                }

                //Add relations from the given data
                result.Relations.ClassType     = result.Relations.ClassType.UnionWith(ontologyData.Relations.ClassType);
                result.Relations.SameAs        = result.Relations.SameAs.UnionWith(ontologyData.Relations.SameAs);
                result.Relations.DifferentFrom = result.Relations.DifferentFrom.UnionWith(ontologyData.Relations.DifferentFrom);
                result.Relations.Assertions    = result.Relations.Assertions.UnionWith(ontologyData.Relations.Assertions);

                //Add annotations from the given data
                result.Annotations.VersionInfo       = result.Annotations.VersionInfo.UnionWith(ontologyData.Annotations.VersionInfo);
                result.Annotations.Comment           = result.Annotations.Comment.UnionWith(ontologyData.Annotations.Comment);
                result.Annotations.Label             = result.Annotations.Label.UnionWith(ontologyData.Annotations.Label);
                result.Annotations.SeeAlso           = result.Annotations.SeeAlso.UnionWith(ontologyData.Annotations.SeeAlso);
                result.Annotations.IsDefinedBy       = result.Annotations.IsDefinedBy.UnionWith(ontologyData.Annotations.IsDefinedBy);
                result.Annotations.CustomAnnotations = result.Annotations.CustomAnnotations.UnionWith(ontologyData.Annotations.CustomAnnotations);
            }
            return(result);
        }