本文整理汇总了C#中TripleStore类的典型用法代码示例。如果您正苦于以下问题:C# TripleStore类的具体用法?C# TripleStore怎么用?C# TripleStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TripleStore类属于命名空间,在下文中一共展示了TripleStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureTestResults
private void EnsureTestResults(TripleStore store)
{
foreach (IGraph g in store.Graphs)
{
TestTools.ShowGraph(g);
Console.WriteLine();
}
Assert.AreEqual(2, store.Graphs.Count, "Expected 2 Graphs");
Assert.AreEqual(8, store.Graphs.Sum(g => g.Triples.Count), "Expected 4 Triples");
IGraph def = store.Graph(null);
IGraph named = store.Graph(new Uri("http://example.org/bnodes#graph"));
HashSet<INode> subjects = new HashSet<INode>();
foreach (Triple t in def.Triples)
{
subjects.Add(t.Subject);
}
foreach (Triple t in named.Triples)
{
subjects.Add(t.Subject);
}
Console.WriteLine("Subjects:");
foreach (INode subj in subjects)
{
Console.WriteLine(subj.ToString() + " from Graph " + (subj.GraphUri != null ? subj.GraphUri.ToString() : "Default"));
}
Assert.AreEqual(4, subjects.Count, "Expected 4 distinct subjects");
}
示例2: SparqlFunctionsIsNumeric
public void SparqlFunctionsIsNumeric()
{
Graph g = new Graph();
IUriNode subj = g.CreateUriNode(new Uri("http://example.org/subject"));
IUriNode pred = g.CreateUriNode(new Uri("http://example.org/predicate"));
g.Assert(subj, pred, (12).ToLiteral(g));
g.Assert(subj, pred, g.CreateLiteralNode("12"));
g.Assert(subj, pred, g.CreateLiteralNode("12", new Uri(XmlSpecsHelper.XmlSchemaDataTypeNonNegativeInteger)));
g.Assert(subj, pred, g.CreateLiteralNode("12", new Uri(XmlSpecsHelper.XmlSchemaDataTypeNonPositiveInteger)));
g.Assert(subj, pred, g.CreateLiteralNode("1200", new Uri(XmlSpecsHelper.XmlSchemaDataTypeByte)));
g.Assert(subj, pred, ((byte)50).ToLiteral(g));
g.Assert(subj, pred, g.CreateLiteralNode("-50", new Uri(XmlSpecsHelper.XmlSchemaDataTypeByte)));
g.Assert(subj, pred, g.CreateLiteralNode("-50", new Uri(XmlSpecsHelper.XmlSchemaDataTypeUnsignedByte)));
g.Assert(subj, pred, g.CreateUriNode(new Uri("http://example.org")));
TripleStore store = new TripleStore();
store.Add(g);
SparqlQueryParser parser = new SparqlQueryParser();
SparqlQuery q = parser.ParseFromString("SELECT ?obj (IsNumeric(?obj) AS ?IsNumeric) WHERE { ?s ?p ?obj }");
Object results = store.ExecuteQuery(q);
Assert.IsTrue(results is SparqlResultSet, "Result should be a SPARQL Result Set");
TestTools.ShowResults(results);
}
示例3: TestExplainProcessor
private void TestExplainProcessor(String query)
{
if (this._processor == null)
{
TripleStore store = new TripleStore();
Graph g = new Graph();
g.LoadFromFile("InferenceTest.ttl");
g.BaseUri = null;
store.Add(g);
this._processor = new ExplainQueryProcessor(store);
}
SparqlQuery q = this._parser.ParseFromString(query);
Object results;
Console.WriteLine("Input Query:");
Console.WriteLine(this._formatter.Format(q));
Console.WriteLine();
Console.WriteLine("Explanation with Default Options (Simulated):");
this._processor.ExplanationLevel = ExplanationLevel.DefaultSimulation;
results = this._processor.ProcessQuery(q);
Console.WriteLine();
Console.WriteLine("Explanation with Default Options:");
this._processor.ExplanationLevel = ExplanationLevel.Default;
results = this._processor.ProcessQuery(q);
Console.WriteLine();
Console.WriteLine("Explanation with Full Options:");
this._processor.ExplanationLevel = ExplanationLevel.Full;
results = this._processor.ProcessQuery(q);
}
示例4: TestConstruct
private void TestConstruct(IGraph data, IGraph expected, String query)
{
TripleStore store = new TripleStore();
store.Add(data);
this.TestConstruct(store, expected, query);
}
示例5: SparqlUpdateLoad
public void SparqlUpdateLoad()
{
TripleStore store = new TripleStore();
LoadCommand loadLondon = new LoadCommand(new Uri("http://dbpedia.org/resource/London"));
LoadCommand loadSouthampton = new LoadCommand(new Uri("http://dbpedia.org/resource/Southampton"), new Uri("http://example.org"));
store.ExecuteUpdate(loadLondon);
store.ExecuteUpdate(loadSouthampton);
Assert.AreEqual(2, store.Graphs.Count, "Should now be 2 Graphs in the Store");
Assert.AreNotEqual(0, store.Triples.Count(), "Should be some Triples in the Store");
foreach (IGraph g in store.Graphs)
{
foreach (Triple t in g.Triples)
{
Console.Write(t.ToString());
if (g.BaseUri != null)
{
Console.WriteLine(" from " + g.BaseUri.ToString());
}
else
{
Console.WriteLine();
}
}
}
}
示例6: TestUpdate
private void TestUpdate(IGraph data, IGraph expected, String update)
{
TripleStore store = new TripleStore();
store.Add(data);
this.TestUpdate(store, expected, update);
}
示例7: Main
static void Main(string[] args)
{
TripleStore ts = new TripleStore(@"http://localhost/SparqlQuery.yada")
{ QueryType = QueryType.RemoteSparqlStore };
var query = from table in new RdfDataContext(ts).ForType<
}
示例8: Setup
public void Setup()
{
this._parser = new SparqlQueryParser();
TripleStore store = new TripleStore();
Graph g = new Graph();
FileLoader.Load(g, "describe-algos.ttl");
store.Add(g);
this._data = new InMemoryDataset(store);
}
示例9: ParsingStoreHandlerBlankNodesTriGActual
public void ParsingStoreHandlerBlankNodesTriGActual()
{
EnsureTestData("test-bnodes.trig");
TriGParser parser = new TriGParser();
TripleStore store = new TripleStore();
parser.Load(store, new StreamParams("test-bnodes.trig"));
EnsureTestResults(store);
}
示例10: CanConvertCannedDcsToRdf
public void CanConvertCannedDcsToRdf()
{
var store = new TripleStore();
var converter = new DublinCoreConverter(store);
converter.Convert(EnumerateCannedInput());
converter.RdfDocument.ExportToN3("testoutputn3.rdf");
converter.RdfDocument.ExportToRdfXml("testoutputXML.rdf");
}
示例11: Query1
public void Query1()
{
var ts = new TripleStore(CreateMemoryStore());
IQueryable<Track> qry = new RdfDataContext(ts).ForType<Track>();
IQueryable<Track> q = from t in qry
where t.ArtistName == "Thomas Laqueur"
select t;
var resultList = new List<Track>();
resultList.AddRange(q);
}
示例12: EnsureTestData
private void EnsureTestData()
{
if (this._data == null)
{
TripleStore store = new TripleStore();
Graph g = new Graph();
g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
store.Add(g);
this._data = new InMemoryDataset(store);
}
}
示例13: EnsureTestData
private void EnsureTestData(String testFile)
{
if (!File.Exists(testFile))
{
TriGParser parser = new TriGParser();
TripleStore store = new TripleStore();
parser.Load(store, new TextReaderParams(new StringReader(TestFragment)));
store.SaveToFile(testFile);
}
}
示例14: JosekiQueryWithProjection
public void JosekiQueryWithProjection()
{
TripleStore ts = new TripleStore(@"http://localhost:2020/music");
IRdfQuery<Track> qry = new RdfDataContext(ts).ForType<Track>();
var q = from t in qry
where t.Year == "2007" &&
t.GenreName == "Rory Blyth: The Smartest Man in the World"
select new { t.Title, t.FileLocation };
foreach (var track in q)
{
Console.WriteLine(track.Title + ": " + track.FileLocation);
}
}
示例15: TestEmptyDatasetParsing
private void TestEmptyDatasetParsing(IStoreReader reader)
{
if (!File.Exists("empty.test"))
{
FileStream temp = File.Create("empty.test");
temp.Close();
}
TripleStore store = new TripleStore();
reader.Load(store, new VDS.RDF.Storage.Params.StreamParams("empty.test"));
Assert.AreEqual(0, store.Graphs.Count, "Store should have no Graphs");
}