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


C# IGraph.Merge方法代码示例

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


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

示例1: ApplyInference

        public static void ApplyInference(IGraph graph, IGraph schema)
        {
            string inverseOf = @"
                PREFIX owl: <http://www.w3.org/2002/07/owl#>
                CONSTRUCT { ?y ?q ?x }
                WHERE { ?p owl:inverseOf ?q .
                        ?x ?p ?y . }
            ";

            var parser = new SparqlQueryParser();

            var rules = new List<SparqlQuery>();
            rules.Add(parser.ParseFromString(inverseOf));

            var store = new TripleStore();
            store.Add(graph, true);
            store.Add(schema, true);

            var queryProcessor = new LeviathanQueryProcessor(store);

            while (true)
            {
                int before = store.Triples.Count();

                foreach (var rule in rules)
                {
                    IGraph inferred = (IGraph)queryProcessor.ProcessQuery(rule);
                    //store.Add(inferred);
                    graph.Merge(inferred);
                }

                int after = store.Triples.Count();

                if (after == before)
                {
                    break;
                }
            }
        }
开发者ID:johnataylor,项目名称:LinkedDataRevisited,代码行数:39,代码来源:Common.cs

示例2: LoadGraph

        /// <summary>
        /// Loads a Graph from the Store
        /// </summary>
        /// <param name="g">Graph to load into</param>
        /// <param name="graphUri">Uri of the Graph to load</param>
        /// <remarks>
        /// If the Graph Uri is null or the Graph doesn't exist in the Store nothing will be returned
        /// </remarks>
        public virtual void LoadGraph(IGraph g, Uri graphUri)
        {
            try
            {
                this.Open(true);

                if (this.Exists(graphUri))
                {
                    if (!g.IsEmpty)
                    {
                        //Load into an Empty Graph and then Merge
                        Graph h = new Graph();
                        this.LoadGraph(h, graphUri);
                        g.Merge(h);

                        //Safe to return as our recursive call will already have closed the connection
                        return;
                    }
                    else
                    {
                        g.BaseUri = graphUri;
                    }

                    //Load Namespaces and Triples
                    String graphID = this.GetGraphID(graphUri);
                    this.LoadNamespaces(g, graphID);
                    this.LoadTriples(g, graphID);
                }
                else
                {
                    if (g.IsEmpty) g.BaseUri = graphUri;
                }

                this.Close(true);
            }
            catch
            {
                this.Close(true, true);
                throw;
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:49,代码来源:BaseStoreManager.cs

示例3: LoadGraph

 /// <summary>
 /// Loads a Graph from the Dataset
 /// </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)
     {
         foreach (Uri u in WriterHelper.StoreDefaultGraphURIs.Select(s => new Uri(s)))
         {
             if (this._store.HasGraph(u))
             {
                 g.Merge(this._store.Graph(u));
                 return;
             }
         }
     }
     else
     {
         if (g.IsEmpty) g.BaseUri = graphUri;
         if (this._store.HasGraph(graphUri))
         {
             g.Merge(this._store.Graph(graphUri));
         }
     }
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:27,代码来源:DatasetFileManager.cs

示例4: LoadGraph

        /// <summary>
        /// Loads a Graph from the SPARQL Endpoint
        /// </summary>
        /// <param name="g">Graph to load into</param>
        /// <param name="graphUri">URI of the Graph to load</param>
        public void LoadGraph(IGraph g, string graphUri)
        {
            String query;

            if (graphUri.Equals(String.Empty))
            {
                if (this._mode == SparqlConnectorLoadMethod.Describe)
                {
                    throw new RdfStorageException("Cannot retrieve the Default Graph when the Load Method is Describe");
                }
                else
                {
                    query = "CONSTRUCT {?s ?p ?o} WHERE {?s ?p ?o}";
                }
            }
            else
            {
                switch (this._mode)
                {
                    case SparqlConnectorLoadMethod.Describe:
                        query = "DESCRIBE <" + graphUri.Replace(">", "\\>") + ">";
                        break;
                    case SparqlConnectorLoadMethod.Construct:
                    default:
                        query = "CONSTRUCT {?s ?p ?o} FROM <" + graphUri.Replace(">", "\\>") + "> WHERE {?s ?p ?o}";
                        break;
                }
            }

            IGraph temp = this._endpoint.QueryWithResultGraph(query);
            if (g.IsEmpty) g.BaseUri = new Uri(graphUri);
            g.Merge(temp);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:38,代码来源:SparqlConnector.cs

示例5: LoadGraph

        /// <summary>
        /// Loads a Graph from the 4store instance
        /// </summary>
        /// <param name="g">Graph to load into</param>
        /// <param name="graphUri">Uri of the Graph to load</param>
        /// <exception cref="RDFStorageExeception"></exception>
        public void LoadGraph(IGraph g, string graphUri)
        {
            try
            {
#if !NO_RWLOCK
                this._lockManager.EnterReadLock();
#endif

                if (!graphUri.Equals(String.Empty))
                {
                    if (g.IsEmpty) g.BaseUri = new Uri(graphUri);
                    g.Merge(this._endpoint.QueryWithResultGraph("CONSTRUCT {?s ?p ?o} FROM <" + graphUri.Replace(">", "\\>") + "> WHERE {?s ?p ?o}"));
                }
                else
                {
                    throw new RdfStorageException("Cannot retrieve a Graph from 4store without specifying a Graph URI");
                }
            }
            finally
            {
#if !NO_RWLOCK
                this._lockManager.ExitReadLock();
#endif
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:31,代码来源:FourStoreConnector.cs

示例6: 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

示例7: LoadGraph

 /// <summary>
 /// Loads a Graph from the Store
 /// </summary>
 /// <param name="g">Graph to load into</param>
 /// <param name="graphUri">Graph URI to load</param>
 public void LoadGraph(IGraph g, Uri graphUri)
 {
     if (this._dataset.HasGraph(graphUri))
     {
         g.Merge(this._dataset[graphUri]);
     }
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:12,代码来源:InMemoryManager.cs


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