私はTopQuadrant Composer Free Edition(TBC FE)を使用して、RDFとして保存されたOWLオントロジにSPARQL/SPINルール(主にSPINコンストラクタ)を埋め込んでいます。このプロセスの一部は、http://spinrdf.org/spで指定されたスキーマを持つhttp://spinrdf.org/sp.htmlに従って、SPARQLソースコードがRDF構造でトークン化/エンコードされていることです。 RDF4Jが実際に解釈してSPINルールを実行するのはこの構造体です。SPARQL/SPINクエリ/ルールをJavaからRDF構造に変換する方法は?
私はまた、私のトリプルストア、リスナー、SPARQLエンドポイント、およびSPINルールエンジンとしてRDF4Jを使用しています。また、データとルールを操作するカスタムJavaコードとGUIを生成しています。
私の質問はJavaでSPARQL/SPINソースコードをRDFとしてエンコードするにはどうすればよいですか?私はではなく、ではクエリ結果をエンコードする方法(別のstackoverflowの質問/応答で答えられました)ではなく、クエリ自体をエンコードする方法を尋ねています。その理由は、TBC FEのみに依存するのではなく、自分のJavaコードからSPINルールを編集できるようにするためです。
また、元のSPARQLクエリテキストを保存するオプションがあることにも注意してください。しかし、トークン化/構造化RDFが正しく解釈されているのに対し、これは正しく解釈されていないという経験があります。したがって、構造化RDFを使用する必要があります。
私は、このコード化を行うJavaコードの多くはおそらくApache Jenaの一部として書かれていることを期待しています。私はちょうどどこを見るかについてのポインタが必要です。
ありがとうございます!
PS:ここに、TBC FEでエンコードされたSPINコンストラクタの例があります。これには、SPARQL/SPINソースコードの元のsp:テキストと(sp:テキストブロックの後の)構造化RDFの開始が含まれます。それは、SPARQLソースコードからJavaを使用して生成できるようにするために必要な、構造化されたRDFです。
<sp:Construct>
<sp:text rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
># [enabled] <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/Pub7#Pub7Proposal_makeRxSCMPointSurface> construct an SCM Point Surface (zero radius) from supporting rx data items under an SCM receiver model
CONSTRUCT {
?this soo:hasSCMReceiverModel ?receiverModelURI .
?receiverModelURI soo:hasSCMPointSurfaceLocation ?pointSurfaceURI .
?pointSurfaceURI soo:SCMPointSurfaceHasPoint ?pointURI .
?pointSurfaceURI a soo:SCMPointSurfaceLocation .
}
WHERE {
?this pub7:pub7ProposalHasDataItem ?rxRadiusDataItem .
?rxRadiusDataItem a pub7:Pub7DataItem406 .
?rxRadiusDataItem soo:hasSCMRadius ?radiusURI .
?radiusURI Nuvio:hasDataValue ?radiusValue .
FILTER (?radiusValue = 0.0000) .
?this pub7:pub7ProposalHasDataItem ?rxPointDataItem .
?rxPointDataItem a pub7:Pub7DataItem403 .
?rxPointDataItem soo:hasSCMPointLocation ?pointURI .
BIND (URI(CONCAT(str(?this), "_rxModel")) AS ?newReceiverModelURI) .
BIND (IF(bound(?existingReceiverModelURI), ?existingReceiverModelURI, ?newReceiverModelURI) AS ?receiverModelURI) .
BIND (URI(CONCAT(str(?receiverModelURI), "_pointSurface")) AS ?pointSurfaceURI) .
}</sp:text>
<rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>[enabled] <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/Pub7#Pub7Proposal_makeRxSCMPointSurface> construct an SCM Point Surface (zero radius) from supporting rx data items under an SCM receiver model</rdfs:comment>
<sp:templates rdf:parseType="Collection">
<rdf:Description>
<sp:object rdf:parseType="Resource">
<sp:varName rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>receiverModelURI</sp:varName>
</sp:object>
<sp:predicate rdf:resource="http://www.disa.mil/dso/a2i/ontologies/PBSM/Sharing/SpectrumOperationsOntology#hasSCMReceiverModel"/>
<sp:subject rdf:resource="http://spinrdf.org/spin#_this"/>
</rdf:Description>
<rdf:Description>
<sp:object rdf:parseType="Resource">
<sp:varName rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>pointSurfaceURI</sp:varName>
</sp:object>
<sp:predicate rdf:resource="http://www.disa.mil/dso/a2i/ontologies/PBSM/Sharing/SpectrumOperationsOntology#hasSCMPointSurfaceLocation"/>
<sp:subject rdf:parseType="Resource">
<sp:varName rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>receiverModelURI</sp:varName>
</sp:subject>
</rdf:Description>
<rdf:Description>
<sp:object rdf:parseType="Resource">
<sp:varName rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>pointURI</sp:varName>
</sp:object>
<sp:predicate rdf:resource="http://www.disa.mil/dso/a2i/ontologies/PBSM/Sharing/SpectrumOperationsOntology#SCMPointSurfaceHasPoint"/>
<sp:subject rdf:parseType="Resource">
<sp:varName rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>pointSurfaceURI</sp:varName>
</sp:subject>
</rdf:Description>
<rdf:Description>
<sp:object rdf:resource="http://www.disa.mil/dso/a2i/ontologies/PBSM/Sharing/SpectrumOperationsOntology#SCMPointSurfaceLocation"/>
<sp:predicate rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"/>
<sp:subject rdf:parseType="Resource">
<sp:varName rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>pointSurfaceURI</sp:varName>
</sp:subject>
</rdf:Description>
</sp:templates>
たぶん私はあなたのテキストで何かを逃したが、なぜあなたは、単に[API](http://topbraid.org/spin/api/)を使用することはできませんか?その特徴の1つは、「テキストSPARQL構文とSPIN RDF語彙との変換」* – AKSW
[例](https://github.com/spinrdf/spinrdf/blob/master/src-examples/org/topbraid/spin /examples/SPINParsingExample.java)は、クエリ文字列からSPIN RDFへの変換を返します。 – AKSW
実際は@AKSW、これは私が探していた答えです。私の質問があまりにも単純ではないことを願っています私はxercesimpl-2.7.1.jar、libthrift-0.9.1.jar、spin-2.0.0.jar、jena 3.4.0 jarファイルを私のプロジェクトに組み込み、パスを構築しました。走るありがとう!私は自分の質問に対する答えとしてこれを掲示することができますが、それは本当にあなたの答えです。あなたが望むなら、答えを投稿することができます。あなたの選択。ありがとう! –