views:

194

answers:

1

is there a way to parse OpenCalais RDF in .NET as i'm using dotnetRDF and it keeps giving me errors. A sample of the Rdf generated may be found in http://viewer.opencalais.com/ , i'm honestly really lost and would really appreciate any help! please help if you use any other apis or know how to make it work with dotnetRDF as i'm honestly really really lost

Erika

<!--Use of the Calais Web Service is governed by the Terms of Service located at http://www.opencalais.com. By using this service or the results of the service you agree to these terms of service.--><!--Relations: PersonEmailAddress

EmailAddress: [email protected], [email protected]
Person: Jack Bauer, Rose Goodings--><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:c="http://s.opencalais.com/1/pred/"&gt;&lt;rdf:Description c:allowDistribution="true" c:allowSearch="true" c:calaisRequestID="5e2f7759-55cb-ac2f-1281-b19ee8118cd9" c:externalID="calaisbridge" c:id="http://id.opencalais.com/KQGwCnWZBLPTHadX7uDMfA" rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/DocInfo"/&gt;&lt;c:document&gt;&lt;![CDATA[Jack Bauer <[email protected]>
Rose Goodings <[email protected]>]]></c:document><c:docTitle/><c:docDate>2010-04-20 07:03:23.998</c:docDate><c:externalMetadata c:caller="calaisbridge"/><c:submitter>calaisbridge</c:submitter></rdf:Description><rdf:Description c:contentType="text/raw" c:emVer="7.1.1103.5" c:langIdVer="DefaultLangId" c:language="InputTextTooShort" c:processingVer="CalaisJob01" c:submissionDate="2010-04-20 07:03:23.905" rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/meta"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/DocInfoMeta"/&gt;&lt;c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/&gt;&lt;c:submitterCode&gt;416dcd8a-766f-0aa3-d94c-e5034b6ffc98&lt;/c:submitterCode&gt;&lt;c:signature&gt;digestalg-1|Kjq/y7thehi10hbBQ5v42YxE8n0=|a2DMjGG4mKEGTlIvvCvOg+BG1sCDrMZFSfRBjOBXMHwGtfLknC1nAQ==&lt;/c:signature&gt;&lt;/rdf:Description&gt;&lt;rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/lid/DefaultLangId"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/lid/DefaultLangId"/&gt;&lt;c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/&gt;&lt;c:lang rdf:resource="http://d.opencalais.com/lid/DefaultLangId/InputTextTooShort"/&gt;&lt;/rdf:Description&gt;&lt;rdf:Description rdf:about="http://d.opencalais.com/pershash-1/a3100b92-7d3d-3f63-afcb-265678c15dcc"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/Person"/&gt;&lt;c:name&gt;Jack Bauer</c:name><c:persontype>N/A</c:persontype><c:nationality>N/A</c:nationality><c:commonname>Jack Bauer</c:commonname></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Instance/1"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/&gt;&lt;c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/&gt;&lt;c:subject rdf:resource="http://d.opencalais.com/pershash-1/a3100b92-7d3d-3f63-afcb-265678c15dcc"/&gt;&lt;!--Person: Jack Bauer; --><c:detection>[]Jack Bauer[ &lt;[email protected]&gt;
Rose Goodings]</c:detection><c:prefix/><c:exact>Jack Bauer</c:exact><c:suffix> &lt;[email protected]&gt;
Rose Goodings</c:suffix><c:offset>0</c:offset><c:length>10</c:length></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Relevance/1"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/RelevanceInfo"/&gt;&lt;c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/&gt;&lt;c:subject rdf:resource="http://d.opencalais.com/pershash-1/a3100b92-7d3d-3f63-afcb-265678c15dcc"/&gt;&lt;c:relevance&gt;0.643&lt;/c:relevance&gt;&lt;/rdf:Description&gt;&lt;rdf:Description rdf:about="http://d.opencalais.com/genericHasher-1/b323806b-4832-375a-aec8-56343d47e2d2"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/EmailAddress"/&gt;&lt;c:name&gt;[email protected]&lt;/c:name&gt;&lt;/rdf:Description&gt;&lt;rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Instance/2"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/&gt;&lt;c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/&gt;&lt;c:subject rdf:resource="http://d.opencalais.com/genericHasher-1/b323806b-4832-375a-aec8-56343d47e2d2"/&gt;&lt;!--EmailAddress: [email protected]; --><c:detection>[Bauer &lt;[email protected]&gt;
Rose Goodings &lt;][email protected][&gt;]</c:detection><c:prefix>Bauer &lt;[email protected]&gt;
Rose Goodings &lt;</c:prefix><c:exact>[email protected]</c:exact><c:suffix>&gt;</c:suffix><c:offset>41</c:offset><c:length>19</c:length></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Relevance/2"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/RelevanceInfo"/&gt;&lt;c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/&gt;&lt;c:subject rdf:resource="http://d.opencalais.com/genericHasher-1/b323806b-4832-375a-aec8-56343d47e2d2"/&gt;&lt;c:relevance&gt;0.643&lt;/c:relevance&gt;&lt;/rdf:Description&gt;&lt;rdf:Description rdf:about="http://d.opencalais.com/genericHasher-1/addbee66-556c-3a3a-b2d4-4c4c1e668261"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/em/r/PersonEmailAddress"/&gt;&lt;!--Rose Goodings--><c:person rdf:resource="http://d.opencalais.com/pershash-1/9f7b3610-9b76-34d4-8eea-3c2c0acbb31b"/&gt;&lt;[email protected]&gt;&lt;c:emailaddress rdf:resource="http://d.opencalais.com/genericHasher-1/b323806b-4832-375a-aec8-56343d47e2d2"/&gt;&lt;/rdf:Description&gt;&lt;rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Instance/3"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/&gt;&lt;c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/&gt;&lt;c:subject rdf:resource="http://d.opencalais.com/genericHasher-1/addbee66-556c-3a3a-b2d4-4c4c1e668261"/&gt;&lt;!--PersonEmailAddress: person: Rose Goodings; emailaddress: [email protected]; --><c:detection>[Bauer &lt;[email protected]&gt;
]Rose Goodings &lt;[email protected][&gt;]</c:detection><c:prefix>Bauer &lt;[email protected]&gt;
</c:prefix><c:exact>Rose Goodings &lt;[email protected]</c:exact><c:suffix>&gt;</c:suffix><c:offset>26</c:offset><c:length>34</c:length></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/pershash-1/9f7b3610-9b76-34d4-8eea-3c2c0acbb31b"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/Person"/&gt;&lt;c:name&gt;Rose Goodings</c:name><c:persontype>N/A</c:persontype><c:nationality>N/A</c:nationality><c:commonname>Rose Goodings</c:commonname></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Instance/4"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/&gt;&lt;c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/&gt;&lt;c:subject rdf:resource="http://d.opencalais.com/pershash-1/9f7b3610-9b76-34d4-8eea-3c2c0acbb31b"/&gt;&lt;!--Person: Rose Goodings; --><c:detection>[Bauer &lt;[email protected]&gt;
]Rose Goodings[ &lt;[email protected]&gt;]</c:detection><c:prefix>Bauer &lt;[email protected]&gt;
</c:prefix><c:exact>Rose Goodings</c:exact><c:suffix> &lt;[email protected]&gt;</c:suffix><c:offset>26</c:offset><c:length>13</c:length></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Relevance/3"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/RelevanceInfo"/&gt;&lt;c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/&gt;&lt;c:subject rdf:resource="http://d.opencalais.com/pershash-1/9f7b3610-9b76-34d4-8eea-3c2c0acbb31b"/&gt;&lt;c:relevance&gt;0.643&lt;/c:relevance&gt;&lt;/rdf:Description&gt;&lt;rdf:Description rdf:about="http://d.opencalais.com/genericHasher-1/8c80538c-84d5-3394-a452-81a59a5eb11a"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/EmailAddress"/&gt;&lt;c:name&gt;[email protected]&lt;/c:name&gt;&lt;/rdf:Description&gt;&lt;rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Instance/5"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/&gt;&lt;c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/&gt;&lt;c:subject rdf:resource="http://d.opencalais.com/genericHasher-1/8c80538c-84d5-3394-a452-81a59a5eb11a"/&gt;&lt;!--EmailAddress: [email protected]; --><c:detection>[Jack Bauer &lt;][email protected][&gt;
Rose Goodings &lt;[email protected]&gt;]</c:detection><c:prefix>Jack Bauer &lt;</c:prefix><c:exact>[email protected]</c:exact><c:suffix>&gt;
Rose Goodings &lt;[email protected]&gt;</c:suffix><c:offset>12</c:offset><c:length>12</c:length></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Relevance/4"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/RelevanceInfo"/&gt;&lt;c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/&gt;&lt;c:subject rdf:resource="http://d.opencalais.com/genericHasher-1/8c80538c-84d5-3394-a452-81a59a5eb11a"/&gt;&lt;c:relevance&gt;0.643&lt;/c:relevance&gt;&lt;/rdf:Description&gt;&lt;rdf:Description rdf:about="http://d.opencalais.com/genericHasher-1/a7bd9537-999f-3821-8858-c57f10ecd18d"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/em/r/PersonEmailAddress"/&gt;&lt;!--Jack Bauer--><c:person rdf:resource="http://d.opencalais.com/pershash-1/a3100b92-7d3d-3f63-afcb-265678c15dcc"/&gt;&lt;[email protected]&gt;&lt;c:emailaddress rdf:resource="http://d.opencalais.com/genericHasher-1/8c80538c-84d5-3394-a452-81a59a5eb11a"/&gt;&lt;/rdf:Description&gt;&lt;rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Instance/6"&gt;&lt;rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/&gt;&lt;c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/&gt;&lt;c:subject rdf:resource="http://d.opencalais.com/genericHasher-1/a7bd9537-999f-3821-8858-c57f10ecd18d"/&gt;&lt;!--PersonEmailAddress: person: Jack Bauer; emailaddress: [email protected]; --><c:detection>[]Jack Bauer &lt;[email protected][&gt;
Rose Goodings &lt;[email protected]&gt;]</c:detection><c:prefix/><c:exact>Jack Bauer &lt;[email protected]</c:exact><c:suffix>&gt;
Rose Goodings &lt;[email protected]&gt;</c:suffix><c:offset>0</c:offset><c:length>24</c:length></rdf:Description></rdf:RDF>

I also have the following (where the file contains the above text):

        System.IO.StreamReader tr = new System.IO.StreamReader("C:/test.txt");
        string s = tr.ReadToEnd();

        Graph g = new Graph();
        FileLoader.Load(g, "C:/test.txt");

and i get the following Exception RDFParseException

StringParser failed to parse the RDF string correctly, StringParser auto-detection guessed 'NTriples' but this failed to parse. RDF string may be malformed or StringParser may have guessed incorrectly

I'm truly lost, please help

+1  A: 

Right the bug was related to the RDF/XML parser not handling CDATA elements correctly in some situations, this should now be fixed and I have uploaded new builds of the library with this bug fix to both dotnetrdf.org and SourceForge

If you download it again and try it on RDF from OpenCalais it should now work fine (I hope)

I try and fix bugs as fast as possible and support my users so if you have any further issues please let me know on the mailing lists so that I can see and address your issues asap:

[email protected]
[email protected]

Edit

For your example application the StringParser does not detect the data format correctly as there is no <?xml version="1.0"?> declaration as it expects to see for RDF/XML

Try the following instead to explicitly set the parser to use:

FileLoader.Load(g, "C:\test.txt", new RdfXmlParser());

Or alternatively rename the file to test.rdf in which case in will guess the data format as RDF/XML from the file extension instead of having to guess by reading in the file and doing some simple regex's on the raw string

RobV
THANK YOU SO MUCH <3 you are honestly a life saver as I was really really lost on what to do -- thank you sooooo much for your help and assistance
Erika