I'm trying to use a RDF library for c# called SemWeb but i'm not beeing able to read my rdf file, wich is 570 MB large because i can't seem to implement any of the examples they give and the documentation is a little poor.
Does anyone use this library or another to parse RDF files?
I need it urgently since i'm doing an university job that 开发者_JAVA百科requires a parser to RDF.
Thanks
To read a file using SemWeb is very simple, just use something like the following:
MemoryStore mem = new MemoryStore();
mem.Import(new N3Reader("file.ttl"));
//Iterate over and print statements
foreach (Statement stmt in mem)
{
Console.WriteLine(stmt.ToString());
}
If your file is RDF/XML then you'd use the RdfXmlReader class instead.
Alternatively you could use my library dotNetRDF to read your file:
Graph g = new Graph();
FileLoader.Load(g, "file.ttl");
//Iterate over and print Triples
foreach (Triple t in g.Triples)
{
Console.WriteLine(t.ToString());
}
Only problem is that if your file is RDF/XML the parser in my library won't handle files of that size currently. If your file is NTriples/Turtle/N3 then you shouldn't have an issue but be prepared to wait for a couple of minutes (for example an ~90MB 1 million triple dataset for the Berlin SPARQL Benchmark takes ~4 minutes to parse but is somewhat dependant on your machine)
This may actually be an issue in general, I'm not sure how the RDF/XML parser in SemWeb is implemented so it may have similar issues to my own with very large files.
Note
Whether this is the best approach for reading your file may depend on what you then intend to do with the data once parsed. There may be more efficient ways to read in/process your data in both SemWeb and dotNetRDF depending on what you intend to then do with that data.
精彩评论