Reputation: 545
What is an effective means of implementing an in memory semantic web triple store using the basic .NET collection classes using F#?
Are there any F# examples or projects already doing this?
Upvotes: 4
Views: 1777
Reputation: 2132
Aduna's Sesame framework is ported to .NET. This is a sample code that shows how to use F# to connect to Sesame Http repository: http://debian.fmi.uni-sofia.bg/~toncho/myblog/archives/309-Using-F-to-connect-to-a-Sesame-repository.html
Upvotes: 1
Reputation: 28646
There is also SemWeb which is a C# library which provides it's own SQL based Triple Store - http://razor.occams.info/code/semweb/
I'm working on a new C# library for RDF called dotNetRDF and have just released the latest Alpha http://www.dotnetrdf.org.
Here's an equivalent program to the one spoon16 showed:
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
My library currently supports my own SQL databases, AllegroGraph, 4store, Joseki, Sesame, Talis and Virtuoso as backing stores
Upvotes: 4
Reputation: 3146
Check out LinqToRdf which, in addition to simple VS.NET hosted modeling tools, provides a full LINQ query provider and round-tripping data when dealing with in-memory databases:
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);
}
Upvotes: 3
Reputation: 99720
I know this doesn't directly answer your question, but you could use 4store which is a stable, proven triplestore, and write a client for it in .Net, instead of developing your own triplestore.
Related questions
Upvotes: 0
Reputation: 48392
Intellidimension offers a .NET based in-memory triple store as part of their Semantics SDK. They often provide free licenses for research/education if you contact them.
I use their technology every single day from C# and PowerShell though and I really enjoy it.
//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
Upvotes: 1