如何使用基本的.NET集合类和F#实现内存中语义Web三元组存储的有效方法?
是否已经有使用F#完成此操作的示例或项目?
如何使用基本的.NET集合类和F#实现内存中语义Web三元组存储的有效方法?
是否已经有使用F#完成此操作的示例或项目?
还有一个名为SemWeb的C#库,它提供了自己的基于SQL的三元组存储 - http://razor.occams.info/code/semweb/
我正在开发一个名为dotNetRDF的新的C#库,用于处理RDF,并刚刚发布了最新的Alpha版本http://www.dotnetrdf.org。
以下是与spoon16展示的程序等效的程序:
open System
open VDS.RDF
open VDS.RDF.Parsing
open VDS.RDF.Query
//Get a Graph and fill it from a file
let g = new Graph()
let parser = new TurtleParser()
parser.Load(g, "test.ttl")
//Place into a Triple Store and query
let store = new TripleStore()
store.Load(g)
let results = store.ExecuteQuery("SELECT ?s ?p ?o WHERE {?s ?p ?o} LIMIT 10") :?> SparqlResultSet
//Output the results
Console.WriteLine(results.Count.ToString() ^ " Results")
for result in results.Results do
Console.WriteLine(result.ToString())
done
//Wait for user to hit enter so they can see the results
Console.ReadLine() |> ignore
我的库目前支持我自己的SQL数据库、AllegroGraph、4store、Joseki、Sesame、Talis和Virtuoso作为后端存储。
请查看LinqToRdf,除了提供简单的VS.NET建模工具外,还提供完整的LINQ查询提供程序和在处理内存数据库时的往返数据功能:
var ctx = new MusicDataContext(@"http://localhost/linqtordf/SparqlQuery.aspx");
var q = (from t in ctx.Tracks
where t.Year == "2006" &&
t.GenreName == "History 5 | Fall 2006 | UC Berkeley"
orderby t.FileLocation
select new {t.Title, t.FileLocation}).Skip(10).Take(5);
foreach (var track in q)
{
Console.WriteLine(track.Title + ": " + track.FileLocation);
}
Intellidimension提供基于.NET的内存三元存储作为Semantics SDK的一部分。如果您联系他们,他们通常会为研究/教育提供免费许可证。
我每天都使用他们的技术来自C#和PowerShell,我真的很喜欢它。
//disclaimer: really the first time I have used F# so this may not be any good...
//but it does work
open Intellidimension.Rdf
open System.IO
let rdfXml = File.ReadAllText(@"C:\ontology.owl")
let gds = new GraphDataSource()
gds.Read(rdfXml) |> ignore
let tbl = gds.Query("select ?s ?p ?o where {?s ?p ?o} limit 10")
System.Console.Write(tbl.RowCount)
System.Console.ReadLine() |> ignore
我知道这不是直接回答你的问题,但你可以使用稳定、经过验证的Triplestore 4store,并编写一个.Net客户端,而不是开发自己的Triplestore。
相关问题