本文整理汇总了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;
}
}
}
示例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;
}
}
示例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));
}
}
}
示例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);
}
示例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
}
}
示例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;
}
}
示例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]);
}
}