概要

RDFトリプルに対して、共起頻度を数える機会がありましたので、備忘録です。以下の記事に続き、今回もジャパンサーチのRDFストアを例にします。

例1

以下は、刀剣タイプのインタンスのうち、共通を作成者(schema:creator )を持つトリプルの数をカウントしています。フィルタによって、同一のインスタンスを避け、また重複カウントを避けています。

s}el??FeeeIcnnLtttTiiE(ttRcyy(o12?uenaantt(tstsi*ycyct)phphyeeee1a:m:msaa!::=?;c;ccrr?oeeeuaannttttooi)rrtyw??2hvveaa&rll&euuee?{e..ntity1<?entity2)

https://jpsearch.go.jp/rdf/sparql/easy/?query=select+(count(*)+as+%3Fcount)+where+{ ++%3Fentity1+a+type%3A刀剣%3B +++++++++++++schema%3Acreator+%3Fvalue+. ++%3Fentity2+a+type%3A刀剣%3B +++++++++++++schema%3Acreator+%3Fvalue+. ++FILTER(%3Fentity1+!%3D+%3Fentity2+%26%26+%3Fentity1+<+%3Fentity2) }

例2

具体的なトリプルを表示してみます。

s}el??FeeeIcnnLtttTiiE?ttReyy(n12?teiaanttytstsi1ycyctphphy?eeee1e:m:mnaa!t::=i;c;ctrr?yeee2aanttt?ooivrrtayl??2uvveaa&ll&wuuhee?eer..neti{ty1<?entity2)

https://jpsearch.go.jp/rdf/sparql/easy/?query=select+%3Fentity1+%3Fentity2+%3Fvalue+where+{ ++%3Fentity1+a+type%3A刀剣%3B +++++++++++++schema%3Acreator+%3Fvalue+. ++%3Fentity2+a+type%3A刀剣%3B +++++++++++++schema%3Acreator+%3Fvalue+. ++FILTER(%3Fentity1+!%3D+%3Fentity2+%26%26+%3Fentity1+<+%3Fentity2) }

共通の値を持つ刀剣タイプのインタンスの一覧を取得することができます。

まとめ

誤っている点もあるかもしれませんが、参考になりましたら幸いです。