当前位置: 首页>>代码示例>>C#>>正文


C# IGraph.Assert方法代码示例

本文整理汇总了C#中IGraph.Assert方法的典型用法代码示例。如果您正苦于以下问题:C# IGraph.Assert方法的具体用法?C# IGraph.Assert怎么用?C# IGraph.Assert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGraph的用法示例。


在下文中一共展示了IGraph.Assert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Replace

        private void Replace(IGraph graph, IUriNode parent, Uri predicate, string jsonField)
        {
            JToken token = null;
            if (_galleryPage.TryGetValue(jsonField, out token))
            {
                JArray array = token as JArray;
                JValue val = token as JValue;

                if (array != null || val != null)
                {
                    var pred = graph.CreateUriNode(predicate);

                    var old = graph.GetTriplesWithSubjectPredicate(parent, pred).ToArray();

                    // remove the old values
                    foreach (var triple in old)
                    {
                        graph.Retract(triple);
                    }

                    if (array != null)
                    {
                        foreach (var child in array)
                        {
                            graph.Assert(parent, pred, graph.CreateLiteralNode(child.ToString()));
                        }
                    }
                    else
                    {
                        graph.Assert(parent, pred, graph.CreateLiteralNode(val.ToString()));
                    }
                }
            }
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:34,代码来源:GalleryGraphAddon.cs

示例2: AddStats

 private void AddStats(IGraph g, IEnumerable<KeyValuePair<INode, long>> stats, INode statsProperty)
 {
     foreach (KeyValuePair<INode, long> kvp in stats)
     {
         g.Assert(kvp.Key.CopyNode(g), statsProperty, kvp.Value.ToLiteral(g));
     }
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:7,代码来源:StatsHandler.cs

示例3: Apply

 public void Apply(IGraph g)
 {
     g.BaseUri = this._baseUri;
     g.Assert(this._triples);
     foreach (KeyValuePair<String, String> ns in this._namespaces)
     {
         g.NamespaceMap.AddNamespace(ns.Key, UriFactory.Create(ns.Value));
     }
 }
开发者ID:jmahmud,项目名称:RDFer,代码行数:9,代码来源:GraphDeserializationInfo.cs

示例4: FromJena

 public static void FromJena(Model m, JenaMapping mapping, IGraph g)
 {
     StmtIterator iter = m.listStatements();
     while (iter.hasNext())
     {
         Statement stmt = iter.nextStatement();
         g.Assert(FromJena(stmt, mapping));
     }
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:9,代码来源:JenaConverter.cs

示例5: MaterializeInference

        public static void MaterializeInference(IGraph graph)
        {
            //  hard code some type inference

            //  nuget:ApiAppPackage rdfs:subClassOf nuget:PackageDetails

            foreach (Triple triple in graph.GetTriplesWithPredicateObject(graph.CreateUriNode(Schema.Predicates.Type), graph.CreateUriNode(Schema.DataTypes.ApiAppPackage)))
            {
                graph.Assert(triple.Subject, triple.Predicate, graph.CreateUriNode(Schema.DataTypes.PackageDetails));
            }

            //  nuget:PowerShellPackage rdfs:subClassOf nuget:PackageDetails

            foreach (Triple triple in graph.GetTriplesWithPredicateObject(graph.CreateUriNode(Schema.Predicates.Type), graph.CreateUriNode(Schema.DataTypes.PowerShellPackage)))
            {
                graph.Assert(triple.Subject, triple.Predicate, graph.CreateUriNode(Schema.DataTypes.PackageDetails));
            }
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:18,代码来源:GraphHelpers.cs

示例6: ApplyToGraph

        /// <summary>
        /// Add data from nuget.packed.json
        /// </summary>
        public override void ApplyToGraph(IGraph graph, IUriNode mainNode)
        {
            Uri mainUri = mainNode.Uri;
            IUriNode typeNode = graph.CreateUriNode(Schema.Predicates.Type);

            // supported frameworks
            if (SupportedFrameworks != null)
            {
                foreach (string framework in SupportedFrameworks)
                {
                    graph.Assert(new Triple(mainNode, graph.CreateUriNode(Schema.Predicates.SupportedFramework), graph.CreateLiteralNode(framework)));
                }
            }

            // assets
            //if (AssetGroups != null)
            //{
            //    int groupId = 0;
            //    foreach (var group in AssetGroups)
            //    {
            //        // group type and id
            //        var groupNode = GetSubNode(graph, mainUri, "assetGroup", "" + groupId);
            //        graph.Assert(groupNode, typeNode, graph.CreateUriNode(PackageAssetGroupType));
            //        graph.Assert(mainNode, graph.CreateUriNode(AssetGroupPredicate), groupNode);
            //        groupId++;

            //        int propId = 0;

            //        // group properties
            //        foreach (var prop in group.Properties)
            //        {
            //            var propNode = GetSubNode(graph, groupNode, "property", "" + propId);
            //            propId++;
            //            graph.Assert(propNode, typeNode, graph.CreateUriNode(PackageAssetGroupPropertyType));
            //            graph.Assert(groupNode, graph.CreateUriNode(AssetGroupPropertyPredicate), propNode);
            //            graph.Assert(propNode, graph.CreateUriNode(AssetKeyPredicate), graph.CreateLiteralNode(prop.Key));
            //            graph.Assert(propNode, graph.CreateUriNode(AssetValuePredicate), graph.CreateLiteralNode(prop.Value));
            //        }

            //        int assetId = 0;

            //        // group items
            //        foreach (var item in group.Items)
            //        {
            //            var itemNode = GetSubNode(graph, groupNode, "asset", "" + assetId);
            //            assetId++;
            //            graph.Assert(itemNode, typeNode, graph.CreateUriNode(PackageAssetType));
            //            graph.Assert(groupNode, graph.CreateUriNode(AssetPredicate), itemNode);

            //            graph.Assert(itemNode, graph.CreateUriNode(AssetTypePredicate), graph.CreateLiteralNode(item.ArtifactType));
            //            graph.Assert(itemNode, graph.CreateUriNode(AssetPathPredicate), graph.CreateLiteralNode(item.Path));
            //        }
            //    }
            //}
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:58,代码来源:PackedData.cs

示例7: FillGraph

        private static void FillGraph(IGraph graph)
        {
            graph.NamespaceMap.AddNamespace("rdf", new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
            graph.NamespaceMap.AddNamespace("ex", new Uri("http://example.org"));
            graph.NamespaceMap.AddNamespace("med", new Uri("http://med.org"));

            IUriNode rdfTypeNode = graph.CreateUriNode("rdf:type");
            IUriNode patienSubjectNode = graph.CreateUriNode(UriFactory.Create("http://ex-hospital-DB/patients/ID98765"));
            IUriNode patientTypeNode = graph.CreateUriNode(UriFactory.Create("http://ex-hospital#patient"));
            IUriNode hasVitalsPredicateNode = graph.CreateUriNode("ex:hasVitals");

            IUriNode odfElementSubjectNode = graph.CreateUriNode(new Uri("med:Sect1"));
            IUriNode odfElementTypeNode = graph.CreateUriNode(UriFactory.Create("http://docs.oasis-open.org/ns/office/1.2/meta/odf#Element"));
            IUriNode vitalDataTypeNode = graph.CreateUriNode("med:vitalData");

            graph.Assert(new Triple(odfElementSubjectNode, rdfTypeNode, vitalDataTypeNode));
            graph.Assert(new Triple(odfElementSubjectNode, rdfTypeNode, odfElementTypeNode));

            graph.Assert(new Triple(patienSubjectNode, rdfTypeNode, patientTypeNode));
            graph.Assert(new Triple(patienSubjectNode, hasVitalsPredicateNode, odfElementSubjectNode));
        }
开发者ID:Tenere,项目名称:Semantic-Lib,代码行数:21,代码来源:Program.cs

示例8: Collect

        public static void Collect(IGraph source, INode subject, IGraph destination, ISet<string> exclude)
        {
            foreach (Triple triple in source.GetTriplesWithSubject(subject))
            {
                destination.Assert(triple.CopyTriple(destination));

                if (triple.Object is IUriNode && !exclude.Contains(((IUriNode)triple.Object).Uri.ToString()))
                {
                    Collect(source, triple.Object, destination, exclude);
                }
            }
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:12,代码来源:GraphSplitting.cs

示例9: ReplaceIRI

        public static void ReplaceIRI(IGraph graph, Uri oldIRI, Uri newIRI)
        {
            // replace the local IRI with the NuGet IRI
            string localUri = oldIRI.AbsoluteUri;

            var triples = graph.Triples.ToArray();

            string mainIRI = newIRI.AbsoluteUri;

            foreach (var triple in triples)
            {
                IUriNode subject = triple.Subject as IUriNode;
                IUriNode objNode = triple.Object as IUriNode;
                INode newSubject = triple.Subject;
                INode newObject = triple.Object;

                bool replace = false;

                if (subject != null && subject.Uri.AbsoluteUri.StartsWith(localUri))
                {
                    // TODO: store these mappings in a dictionary
                    Uri iri = new Uri(String.Format(CultureInfo.InvariantCulture, "{0}{1}", mainIRI, subject.Uri.AbsoluteUri.Substring(localUri.Length)));
                    newSubject = graph.CreateUriNode(iri);
                    replace = true;
                }

                if (objNode != null && objNode.Uri.AbsoluteUri.StartsWith(localUri))
                {
                    // TODO: store these mappings in a dictionary
                    Uri iri = new Uri(String.Format(CultureInfo.InvariantCulture, "{0}{1}", mainIRI, objNode.Uri.AbsoluteUri.Substring(localUri.Length)));
                    newObject = graph.CreateUriNode(iri);
                    replace = true;
                }

                if (replace)
                {
                    graph.Assert(newSubject, triple.Predicate, newObject);
                    graph.Retract(triple);
                }
            }
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:41,代码来源:CantonUtilities.cs

示例10: Apply

 /// <summary>
 /// Applies the reasoner to the given input Graph outputting inferences into the output Graph
 /// </summary>
 /// <param name="input">Input Graph</param>
 /// <param name="output">Output Graph</param>
 public virtual void Apply(IGraph input, IGraph output)
 {
     output.Assert(this._reasoner.Extract(OwlHelper.OwlExtractMode.AllStatements));
 }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:9,代码来源:OwlReasonerWrapper.cs

示例11: LoadGraph

        /// <summary>
        /// Loads a Graph from the Quad Store
        /// </summary>
        /// <param name="g">Graph to load into</param>
        /// <param name="graphUri">Uri of the Graph to Load</param>
        public void LoadGraph(IGraph g, Uri graphUri)
        {
            if (graphUri == null) throw new RdfStorageException("Cannot load an unnamed Graph from Virtuoso as this would require loading the entirety of the Virtuoso Quad Store into memory!");

            if (!g.IsEmpty)
            {
                //Do the load into a new Empty Graph and then do a merge
                Graph h = new Graph();
                this.LoadGraph(h, graphUri);
                g.Merge(h);
                return;
            }

            try
            {
                g.BaseUri = graphUri;

                //Need to keep Database Open as Literals require extra trips to the Database to get additional
                //information about Language and Type
                this.Open(false);

                DataTable data = this.LoadTriples(graphUri);

                foreach (DataRow row in data.Rows)
                {
                    Object s, p, o;
                    INode subj, pred, obj;

                    //Get Data
                    s = row["S"];
                    p = row["P"];
                    o = row["O"];

                    //Create Nodes
                    subj = this.LoadNode(g, s);
                    pred = this.LoadNode(g, p);
                    obj = this.LoadNode(g, o);

                    //Assert Triple
                    g.Assert(new Triple(subj, pred, obj));
                }
                this.Close(false);
            }
            catch
            {
                this.Close(true);
                throw;
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:54,代码来源:VirtuosoManager.cs

示例12: Rebase

        public static void Rebase(IGraph source, IGraph destination, Uri sourceUri, Uri destinationUri)
        {
            Uri modifiedDestinationUri = new Uri(destinationUri.ToString().Replace('#', '/'));

            foreach (Triple triple in source.Triples)
            {
                Uri subjectUri;
                if (triple.Subject.ToString() == destinationUri.ToString())
                {
                    subjectUri = modifiedDestinationUri;
                }
                else
                {
                    subjectUri = RebaseUri(((IUriNode)triple.Subject).Uri, sourceUri, modifiedDestinationUri);
                }

                INode subjectNode = destination.CreateUriNode(subjectUri);
                INode predicateNode = triple.Predicate.CopyNode(destination);

                INode objectNode;
                if (triple.Object is IUriNode)
                {
                    Uri objectUri = RebaseUri(((IUriNode)triple.Object).Uri, sourceUri, modifiedDestinationUri);
                    objectNode = destination.CreateUriNode(objectUri);
                }
                else
                {
                    objectNode = triple.Object.CopyNode(destination);
                }

                destination.Assert(subjectNode, predicateNode, objectNode);
            }
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:33,代码来源:GraphSplitting.cs

示例13: Apply

        /// <summary>
        /// Applies inference to the Input Graph and outputs the inferred information to the Output Graph
        /// </summary>
        /// <param name="input">Graph to apply inference to</param>
        /// <param name="output">Graph inferred information is output to</param>
        public virtual void Apply(IGraph input, IGraph output)
        {
            //Infer information
            List<Triple> inferences = new List<Triple>();
            foreach (Triple t in input.Triples)
            {
                //Apply class/property hierarchy inferencing
                if (t.Predicate.Equals(this._rdfType))
                {
                    if (!t.Object.Equals(this._rdfsClass) && !t.Object.Equals(this._rdfProperty))
                    {
                        this.InferClasses(t, input, output, inferences);
                    }
                }
                else if (t.Predicate.Equals(this._rdfsSubClass))
                {
                    //Assert that this thing is a Class
                    inferences.Add(new Triple(t.Subject.CopyNode(output), this._rdfType.CopyNode(output), this._rdfsClass.CopyNode(output)));
                }
                else if (t.Predicate.Equals(this._rdfsSubProperty))
                {
                    //Assert that this thing is a Property
                    inferences.Add(new Triple(t.Subject.CopyNode(output), this._rdfType.CopyNode(output), this._rdfProperty.CopyNode(output)));
                }
                else if (this._propertyMappings.ContainsKey(t.Predicate))
                {
                    INode property = t.Predicate;

                    //Navigate up the property hierarchy asserting additional properties if able
                    while (this._propertyMappings.ContainsKey(property))
                    {
                        if (this._propertyMappings[property] != null)
                        {
                            //Assert additional properties
                            inferences.Add(new Triple(t.Subject.CopyNode(output), this._propertyMappings[property].CopyNode(output), t.Object.CopyNode(output)));
                            property = this._propertyMappings[property];
                        }
                        else
                        {
                            break;
                        }
                    }
                }

                //Apply Domain and Range inferencing on Predicates
                if (this._rangeMappings.ContainsKey(t.Predicate))
                {
                    //Assert additional type information
                    foreach (INode n in this._rangeMappings.GetValues(t.Predicate))
                    {
                        inferences.Add(new Triple(t.Object.CopyNode(output), this._rdfType.CopyNode(output), n.CopyNode(output)));
                    }

                    //Call InferClasses to get extra type information
                    this.InferClasses(inferences[inferences.Count - 1], input, output, inferences);
                }
                if (this._domainMappings.ContainsKey(t.Predicate))
                {
                    //Assert additional type information
                    foreach (INode n in this._domainMappings.GetValues(t.Predicate))
                    {
                        inferences.Add(new Triple(t.Subject.CopyNode(output), this._rdfType.CopyNode(output), n.CopyNode(output)));
                    }
                    
                    //Call InferClasses to get extra type information
                    this.InferClasses(inferences[inferences.Count - 1], input, output, inferences);
                }
            }

            //Assert the inferred information
            inferences.RemoveAll(t => t.Subject.NodeType == NodeType.Literal);
            if (inferences.Count > 0)
            {
                output.Assert(inferences);
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:81,代码来源:RDFSReasoner.cs

示例14: Reverse

        public static void Reverse(IGraph graph, Uri existingProperty, Uri reverseProperty)
        {
            var existingTriples = graph
                .GetTriplesWithPredicate(graph.CreateUriNode(existingProperty))
                .ToList();

            graph.Retract(existingTriples);

            INode predicate = graph.CreateUriNode(reverseProperty);
            foreach (var existingTriple in existingTriples)
            {
                graph.Assert(existingTriple.Object, predicate, existingTriple.Subject);
            }
        }
开发者ID:johnataylor,项目名称:LinkedDataRevisited,代码行数:14,代码来源:Common.cs

示例15: Apply

        /// <summary>
        /// Applies inference to the Input Graph and outputs the inferred information to the Output Graph
        /// </summary>
        /// <param name="input">Graph to apply inference to</param>
        /// <param name="output">Graph inferred information is output to</param>
        public virtual void Apply(IGraph input, IGraph output)
        {
            List<Triple> inferences = new List<Triple>();
            lock (this._conceptMappings)
            {
                foreach (Triple t in input.Triples)
                {
                    if (!(t.Predicate.Equals(this._skosBroader) || t.Predicate.Equals(this._skosNarrower)) && this._conceptMappings.ContainsKey(t.Object))
                    {
                        INode concept = t.Object;
                        while (this._conceptMappings.ContainsKey(concept))
                        {
                            if (this._conceptMappings[concept] != null)
                            {
                                //Assert additional information
                                inferences.Add(new Triple(t.Subject.CopyNode(output), t.Predicate.CopyNode(output), this._conceptMappings[concept].CopyNode(output)));
                                concept = this._conceptMappings[concept];
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }

            if (inferences.Count > 0)
            {
                output.Assert(inferences);
            }
        }
开发者ID:jmahmud,项目名称:RDFer,代码行数:37,代码来源:SKOSReasoner.cs


注:本文中的IGraph.Assert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。