OpenCalais Parse RDF в .NET - PullRequest
       28

OpenCalais Parse RDF в .NET

2 голосов
/ 20 апреля 2010

есть ли способ проанализировать RDF OpenCalais в .NET, так как я использую dotnetRDF, и он продолжает давать мне ошибки. Образец сгенерированного Rdf можно найти в http://viewer.opencalais.com/, я, честно говоря, действительно потерян и буду очень признателен за любую помощь! пожалуйста, помогите, если вы используете какой-либо другой API-интерфейс или знаете, как заставить его работать с dotnetRDF, потому что, честно говоря, я действительно очень потерян

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>

У меня также есть следующее (где файл содержит текст выше):

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

и я получаю следующее исключение RDFParseException

StringParser не удалось правильно проанализировать строку RDF, автоопределение StringParser додумалось до NTriples, но это не удалось проанализировать. Возможно, строка RDF неверна или StringParser неправильно угадал

Я действительно потерян, пожалуйста, помогите

1 Ответ

2 голосов
/ 20 апреля 2010

Правильно, ошибка была связана с тем, что синтаксический анализатор RDF / XML неправильно обрабатывал элементы CDATA в некоторых ситуациях, теперь это нужно исправить, и я загрузил новые сборки библиотеки с этим исправлением ошибки в оба dotnetrdf.org и SourceForge

Если вы загрузите его снова и попробуете его на RDF из OpenCalais, то теперь оно должно работать нормально (я надеюсь)

Я стараюсь исправлять ошибки как можно быстрее и поддерживаю своих пользователей, поэтому, если у вас возникнут какие-либо проблемы, пожалуйста, сообщите мне об этом в списках рассылки, чтобы я мог видеть и решать ваши проблемы как можно скорее:

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

Редактировать

Для вашего примера приложения StringParser не может правильно определить формат данных, так как отсутствует объявление <?xml version="1.0"?>, которое он ожидает увидеть для RDF / XML

Вместо этого попробуйте следующее, чтобы явно использовать синтаксический анализатор:

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

Или, альтернативно, переименуйте файл в test.rdf, и в этом случае он будет угадывать формат данных как RDF / XML из расширения файла, вместо того, чтобы угадывать, читая файл и выполняя некоторые простые регулярные выражения для необработанной строки

...