質問

dotnetrdfを使用しているので、.netでOpenCalais RDFを解析する方法はありますか?生成されたRDFのサンプルは http://viewer.opencalais.com/ 、私は正直に本当に迷子になり、どんな助けにも本当に感謝しています!他のAPIを使用したり、dotnetrdfで動作させる方法を知っている場合は助けてください。

エリカ

<!--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 Auto-retectionは「ntriples」を推測しましたが、これは解析できませんでした。 RDF文字列が奇形であるか、StringParserが誤って推測している可能性があります

私は本当に迷っています、助けてください

役に立ちましたか?

解決

バグはRDF/XMLパーサーに関連していました。CDATA要素を正しく処理しない状況によっては、これを修正する必要があります。 dotnetrdf.org およびsourceforge

もう一度ダウンロードして、OpenCalaisからRDFで試してみると、正常に動作するはずです(私は願っています)

私はバグをできるだけ速く修正してユーザーをサポートしようとしているので、それ以上の問題がある場合は、メーリングリストでお知らせください。

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 その場合、ファイルを読んでRaw文字列で簡単なRegexを実行することで推測する代わりに、ファイル拡張機能のRDF/XMLとしてデータ形式を推測します

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top