本文整理汇总了C#中Graph.GetTriplesWithSubject方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.GetTriplesWithSubject方法的具体用法?C# Graph.GetTriplesWithSubject怎么用?C# Graph.GetTriplesWithSubject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.GetTriplesWithSubject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GraphDiffRemovedGroundTriples
public void GraphDiffRemovedGroundTriples()
{
Graph g = new Graph();
Graph h = new Graph();
FileLoader.Load(g, "InferenceTest.ttl");
FileLoader.Load(h, "InferenceTest.ttl");
//Remove Triples about Ford Fiestas from 2nd Graph
h.Retract(h.GetTriplesWithSubject(new Uri("http://example.org/vehicles/FordFiesta")));
GraphDiffReport report = g.Difference(h);
TestTools.ShowDifferences(report);
Assert.IsFalse(report.AreEqual, "Graphs should not have been reported as equal");
Assert.IsTrue(report.RemovedTriples.Any(), "Difference should have reported some Removed Triples");
}
示例2: StorageSesameDeleteTriples
public void StorageSesameDeleteTriples()
{
try
{
Graph g = new Graph();
FileLoader.Load(g, "InferenceTest.ttl");
g.BaseUri = new Uri("http://example.org/SesameTest");
SesameHttpProtocolConnector sesame = new SesameHttpProtocolConnector("http://nottm-virtual.ecs.soton.ac.uk:8080/openrdf-sesame/", "unit-test");
sesame.SaveGraph(g);
Console.WriteLine("Graph before deletion");
TestTools.ShowGraph(g);
//Delete all Triples about the Ford Fiesta
sesame.UpdateGraph(g.BaseUri, null, g.GetTriplesWithSubject(new Uri("http://example.org/vehicles/FordFiesta")));
Object results = sesame.Query("ASK WHERE { <http://example.org/vehicles/FordFiesta> ?p ?o }");
if (results is SparqlResultSet)
{
Assert.IsFalse(((SparqlResultSet)results).Result, "There should no longer be any triples about the Ford Fiesta present");
}
Graph h = new Graph();
sesame.LoadGraph(h, g.BaseUri);
Console.WriteLine("Graph after deletion");
TestTools.ShowGraph(h);
Assert.IsFalse(h.IsEmpty, "Graph should not be completely empty");
Assert.IsTrue(g.HasSubGraph(h), "Graph retrieved with missing Triples should be a sub-graph of the original Graph");
Assert.IsFalse(g.Equals(h), "Graph retrieved should not be equal to original Graph");
}
catch (Exception ex)
{
TestTools.ReportError("Error", ex, true);
}
}
示例3: StorageAllegroGraphDeleteTriples
public void StorageAllegroGraphDeleteTriples()
{
try
{
Graph g = new Graph();
FileLoader.Load(g, "InferenceTest.ttl");
g.BaseUri = new Uri("http://example.org/AllegroGraphTest");
AllegroGraphConnector agraph = new AllegroGraphConnector("http://localhost:9875", "test", "unit-test");
agraph.SaveGraph(g);
Console.WriteLine("Graph before deletion");
TestTools.ShowGraph(g);
//Delete all Triples about the Ford Fiesta
agraph.UpdateGraph(g.BaseUri, null, g.GetTriplesWithSubject(new Uri("http://example.org/vehicles/FordFiesta")));
Graph h = new Graph();
agraph.LoadGraph(h, g.BaseUri);
Console.WriteLine("Graph after deletion");
TestTools.ShowGraph(h);
Assert.IsFalse(h.IsEmpty, "Graph should not be completely empty");
Assert.IsTrue(g.HasSubGraph(h), "Graph retrieved with missing Triples should be a sub-graph of the original Graph");
Assert.IsFalse(g.Equals(h), "Graph retrieved should not be equal to original Graph");
Object results = agraph.Query("ASK WHERE { GRAPH <http://example.org/AllegroGraphTest> { <http://example.org/vehicles/FordFiesta> ?p ?o } }");
if (results is SparqlResultSet)
{
Assert.IsFalse(((SparqlResultSet)results).Result, "There should no longer be any triples about the Ford Fiesta present");
}
}
catch (Exception ex)
{
TestTools.ReportError("Error", ex, true);
}
}
示例4: GraphDiffRemovedMSG
public void GraphDiffRemovedMSG()
{
Graph g = new Graph();
Graph h = new Graph();
FileLoader.Load(g, "InferenceTest.ttl");
FileLoader.Load(h, "InferenceTest.ttl");
//Remove MSG from 2nd Graph
h.Retract(h.GetTriplesWithSubject(h.GetBlankNode("autos1")));
GraphDiffReport report = g.Difference(h);
TestTools.ShowDifferences(report);
Assert.IsFalse(report.AreEqual, "Graphs should not have been reported as equal");
Assert.IsTrue(report.RemovedMSGs.Any(), "Difference should have reported some Removed MSGs");
}