Pergunta

Existe uma maneira de analisar o OpenCalais RDF no .NET enquanto estou usando o DotnetrDF e continua me dando erros. Uma amostra do RDF gerada pode ser encontrada em http://viewer.opencalais.com/ Sinceramente, estou muito perdido e realmente apreciaria qualquer ajuda! Por favor, ajude se você usar outras APIs ou saber como fazê -lo funcionar com o dotnetrdf, pois estou honestamente realmente perdido

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: jack@ctu.net, r.good@testings.com
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/"><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"><rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/DocInfo"/><c:document><![CDATA[Jack Bauer <jack@ctu.net>
Rose Goodings <r.good@testings.com>]]></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"><rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/DocInfoMeta"/><c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/><c:submitterCode>416dcd8a-766f-0aa3-d94c-e5034b6ffc98</c:submitterCode><c:signature>digestalg-1|Kjq/y7thehi10hbBQ5v42YxE8n0=|a2DMjGG4mKEGTlIvvCvOg+BG1sCDrMZFSfRBjOBXMHwGtfLknC1nAQ==</c:signature></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/lid/DefaultLangId"><rdf:type rdf:resource="http://s.opencalais.com/1/type/lid/DefaultLangId"/><c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/><c:lang rdf:resource="http://d.opencalais.com/lid/DefaultLangId/InputTextTooShort"/></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/pershash-1/a3100b92-7d3d-3f63-afcb-265678c15dcc"><rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/Person"/><c:name>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"><rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/><c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/><c:subject rdf:resource="http://d.opencalais.com/pershash-1/a3100b92-7d3d-3f63-afcb-265678c15dcc"/><!--Person: Jack Bauer; --><c:detection>[]Jack Bauer[ &lt;jack@ctu.net&gt;
Rose Goodings]</c:detection><c:prefix/><c:exact>Jack Bauer</c:exact><c:suffix> &lt;jack@ctu.net&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"><rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/RelevanceInfo"/><c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/><c:subject rdf:resource="http://d.opencalais.com/pershash-1/a3100b92-7d3d-3f63-afcb-265678c15dcc"/><c:relevance>0.643</c:relevance></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/genericHasher-1/b323806b-4832-375a-aec8-56343d47e2d2"><rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/EmailAddress"/><c:name>r.good@testings.com</c:name></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Instance/2"><rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/><c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/><c:subject rdf:resource="http://d.opencalais.com/genericHasher-1/b323806b-4832-375a-aec8-56343d47e2d2"/><!--EmailAddress: r.good@testings.com; --><c:detection>[Bauer &lt;jack@ctu.net&gt;
Rose Goodings &lt;]r.good@testings.com[&gt;]</c:detection><c:prefix>Bauer &lt;jack@ctu.net&gt;
Rose Goodings &lt;</c:prefix><c:exact>r.good@testings.com</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"><rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/RelevanceInfo"/><c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/><c:subject rdf:resource="http://d.opencalais.com/genericHasher-1/b323806b-4832-375a-aec8-56343d47e2d2"/><c:relevance>0.643</c:relevance></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/genericHasher-1/addbee66-556c-3a3a-b2d4-4c4c1e668261"><rdf:type rdf:resource="http://s.opencalais.com/1/type/em/r/PersonEmailAddress"/><!--Rose Goodings--><c:person rdf:resource="http://d.opencalais.com/pershash-1/9f7b3610-9b76-34d4-8eea-3c2c0acbb31b"/><!--r.good@testings.com--><c:emailaddress rdf:resource="http://d.opencalais.com/genericHasher-1/b323806b-4832-375a-aec8-56343d47e2d2"/></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Instance/3"><rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/><c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/><c:subject rdf:resource="http://d.opencalais.com/genericHasher-1/addbee66-556c-3a3a-b2d4-4c4c1e668261"/><!--PersonEmailAddress: person: Rose Goodings; emailaddress: r.good@testings.com; --><c:detection>[Bauer &lt;jack@ctu.net&gt;
]Rose Goodings &lt;r.good@testings.com[&gt;]</c:detection><c:prefix>Bauer &lt;jack@ctu.net&gt;
</c:prefix><c:exact>Rose Goodings &lt;r.good@testings.com</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"><rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/Person"/><c:name>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"><rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/><c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/><c:subject rdf:resource="http://d.opencalais.com/pershash-1/9f7b3610-9b76-34d4-8eea-3c2c0acbb31b"/><!--Person: Rose Goodings; --><c:detection>[Bauer &lt;jack@ctu.net&gt;
]Rose Goodings[ &lt;r.good@testings.com&gt;]</c:detection><c:prefix>Bauer &lt;jack@ctu.net&gt;
</c:prefix><c:exact>Rose Goodings</c:exact><c:suffix> &lt;r.good@testings.com&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"><rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/RelevanceInfo"/><c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/><c:subject rdf:resource="http://d.opencalais.com/pershash-1/9f7b3610-9b76-34d4-8eea-3c2c0acbb31b"/><c:relevance>0.643</c:relevance></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/genericHasher-1/8c80538c-84d5-3394-a452-81a59a5eb11a"><rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/EmailAddress"/><c:name>jack@ctu.net</c:name></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Instance/5"><rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/><c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/><c:subject rdf:resource="http://d.opencalais.com/genericHasher-1/8c80538c-84d5-3394-a452-81a59a5eb11a"/><!--EmailAddress: jack@ctu.net; --><c:detection>[Jack Bauer &lt;]jack@ctu.net[&gt;
Rose Goodings &lt;r.good@testings.com&gt;]</c:detection><c:prefix>Jack Bauer &lt;</c:prefix><c:exact>jack@ctu.net</c:exact><c:suffix>&gt;
Rose Goodings &lt;r.good@testings.com&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"><rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/RelevanceInfo"/><c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/><c:subject rdf:resource="http://d.opencalais.com/genericHasher-1/8c80538c-84d5-3394-a452-81a59a5eb11a"/><c:relevance>0.643</c:relevance></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/genericHasher-1/a7bd9537-999f-3821-8858-c57f10ecd18d"><rdf:type rdf:resource="http://s.opencalais.com/1/type/em/r/PersonEmailAddress"/><!--Jack Bauer--><c:person rdf:resource="http://d.opencalais.com/pershash-1/a3100b92-7d3d-3f63-afcb-265678c15dcc"/><!--jack@ctu.net--><c:emailaddress rdf:resource="http://d.opencalais.com/genericHasher-1/8c80538c-84d5-3394-a452-81a59a5eb11a"/></rdf:Description><rdf:Description rdf:about="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902/Instance/6"><rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/><c:docId rdf:resource="http://d.opencalais.com/dochash-1/e7b46664-fa0c-3da1-88f9-cb79fe0d6902"/><c:subject rdf:resource="http://d.opencalais.com/genericHasher-1/a7bd9537-999f-3821-8858-c57f10ecd18d"/><!--PersonEmailAddress: person: Jack Bauer; emailaddress: jack@ctu.net; --><c:detection>[]Jack Bauer &lt;jack@ctu.net[&gt;
Rose Goodings &lt;r.good@testings.com&gt;]</c:detection><c:prefix/><c:exact>Jack Bauer &lt;jack@ctu.net</c:exact><c:suffix>&gt;
Rose Goodings &lt;r.good@testings.com&gt;</c:suffix><c:offset>0</c:offset><c:length>24</c:length></rdf:Description></rdf:RDF>

Eu também tenho o seguinte (onde o arquivo contém o texto acima):

        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");

E eu recebo a seguinte exceção rdfparseException

StringParser falhou em analisar a string RDF corretamente, a detecção automática de StringParser adivinhou 'ntriples', mas isso não conseguiu analisar. String rdf pode ser malformada ou stringparser pode ter adivinhado incorretamente

Estou realmente perdido, por favor me ajude

Foi útil?

Solução

DIREITO O bug estava relacionado ao analisador RDF/XML, que não lidando com os elementos CDATA corretamente em algumas situações, isso agora deve ser corrigido e eu enviei novas construções da biblioteca com essa correção de bug para ambos dotnetrdf.org e sourceforge

Se você baixá -lo novamente e experimente no RDF da OpenCalais, agora deve funcionar bem (espero)

Eu tento corrigir bugs o mais rápido possível e apoio meus usuários; portanto, se você tiver mais problemas, informe -me nas listas de discussão para que eu possa ver e resolver seus problemas o mais rápido possível:

dotnetrdf-bugs@lists.sourceforge.net
dotnetrdf-develop@lists.sourceforge.net

Editar

Para o seu exemplo de aplicativo, o StringParser não detecta o formato de dados corretamente, pois não há <?xml version="1.0"?> Declaração como espera ver para RDF/XML

Tente o seguinte para definir explicitamente o analisador para usar:

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

Ou renomear alternativamente o arquivo para test.rdf nesse caso, adivinhará o formato de dados como RDF/XML da extensão do arquivo, em vez de ter que adivinhar lendo no arquivo e fazendo alguns regex simples na string crua

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top