From: Kenneth G. <sp...@gm...> - 2013-02-15 13:51:27
|
Hi, I am currently creating some code to resolve an RDF source. I'm pretty new to dotNetRdf, so sorry in advance if this is a silly mistake. Here is what I do: 1. Initialize store and load initial graph IInMemoryQueryableStore store = new TripleStore()) UriLoader.Load(graph, new Uri(resource)); 3. Start resolving objects that are UriNodes: foreach (Triple triple in graph.Triples) { switch (triple.Object.NodeType) { case NodeType.Uri: { string predicateTitle = ResolveTitle(triple.Predicate, store); string objectTitle = ResolveTitle(triple.Object, store); ... What ResolveTitle basically does is that it searches the Store for any matching subjects: string ResolveTitle(INode node, IInMemoryQueryableStore store) { IEnumerable<Triple> triples = store.GetTriplesWithSubject(node); If it can't find any subjects in the store that matches the node, it resolves the URI, and puts it into the store Graph g = new Graph(); g.LoadFromUri(node.Uri); store.Add(g); and tries the matching again. This approach seems to work fine, except that in some cases the Object looks like this: triple.Object {*http://sws.geonames.org/3161732*} VDS.RDF.INode {VDS.RDF.UriNode} while the loaded Graph in the store has Triples that look like this: VDS.RDF.Triple {*http://sws.geonames.org/3161732/* , http://www.geonames.org/ontology#name , Bergen} As you can see, the Subject has a trailing slash, while the Object does not have a trailing slash. So when it tries to find any matching triples: IEnumerable<Triple> triples = store.GetTriplesWithSubject(node); it returns none, since they do not match. Am I misunderstanding something? Is there a way to make sure my object and the subject in the store is actually the same? Also, it would be nice with some feedback if my approach to this is totally wrong :) Best regards, Kenneth |