n3在EulerSharp中将str:conths应用于xsd:string的推理



我有一个数据集,其中包含大量我需要的资源根据各种现有数据进行对账。最直接的方法是在各种文字。

不幸的是,文本类型为xsd:string,并且EulerSharp内置str:contains无法处理类型化的文字。

我已经阅读了我能在eulersharp内置和我最接近的方法是尝试将xsd:string强制转换为使用rdf:PlainLiteral谓词的PlainLiteral;然而这似乎没有得到EulerSharp的支持。

如何操作和比较xsd:string类型的Literals?

或者,我应该对数据进行预处理以剥离数据类型吗?

以下.n3文件演示了该问题:

@prefix : <http://local#> .
@prefix str: <http://www.w3.org/2000/10/swap/string#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:Bob :name "Bob Smith" .
:Rob :name "Rob Smith"^^xsd:string .
{ ?P :name ?N .
  ?N str:contains "Smith" } => { ?P :bingo ?N } .

以及运行上述文件的结果:

$ eye --swipl test.n3 --pass --nope
Id: euler.yap 5974 2013-02-12 00:29:00Z josd
SWI-Prolog 5.10.4 (amd64): Dec 27 2011, 08:54:16
starting 80 [msec cputime] 78 [msec walltime]
GET file:///home/ubuntu/src/test/test.n3 SC=4
networking 0 [msec cputime] 2 [msec walltime]
#Processed by Id: euler.yap 5974 2013-02-12 00:29:00Z josd
#eye --swipl test.n3 --pass --nope
@prefix : <http://local#>.
@prefix str: <http://www.w3.org/2000/10/swap/string#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix var: <http://localhost/var#>.
@prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>.
@prefix r: <http://www.w3.org/2000/10/swap/reason#>.
@prefix n3: <http://www.w3.org/2004/06/rei#>.
:Bob :name "Bob Smith".
:Rob :name "Rob Smith"^^xsd:string.
:Bob :bingo "Bob Smith".
TC=4 TP=8 BC=0 BP=5 PM=0 CM=0 FM=0 AM=0
reasoning 0 [msec cputime] 4 [msec walltime]
#ENDS 0 [msec] TC=4 TP=8 BC=0 BP=5 PM=0 CM=0 FM=0 AM=0

我在EulerSharp列表上询问并收到了以下回复:

您可以通过log:dtlit从数据类型文本中获取文本。

额外的规则会让它发挥作用。

不是那样吗?dt您也可以使用xsd:string

@prefix : <http://local#> .
@prefix str: <http://www.w3.org/2000/10/swap/string#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#>.

:Bob :name "Bob Smith" .
:Rob :name "Rob Smith"^^xsd:string .
{ ?P :name ?N .
  ?N str:contains "Smith" } => { ?P :bingo ?N } .
{ ?P :name ?N .
  (?lit ?dt) log:dtlit ?N.
  ?lit str:contains "Smith" } => { ?P :bingo ?N } .

运行此操作会得到所需的结果:

$ eye --swipl test.n3 --pass --nope
Id: euler.yap 5974 2013-02-12 00:29:00Z josd
SWI-Prolog 5.10.4 (amd64): Dec 27 2011, 08:54:16
starting 50 [msec cputime] 62 [msec walltime]
#Processed by Id: euler.yap 5974 2013-02-12 00:29:00Z josd
#eye --swipl test.n3 --pass --nope
GET file:///home/ubuntu/src/test/test.n3 SC=4
networking 10 [msec cputime] 2 [msec walltime]
@prefix : <http://local#>.
@prefix str: <http://www.w3.org/2000/10/swap/string#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix var: <http://localhost/var#>.
@prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>.
@prefix r: <http://www.w3.org/2000/10/swap/reason#>.
@prefix n3: <http://www.w3.org/2004/06/rei#>.
:Bob :name "Bob Smith".
:Rob :name "Rob Smith"^^xsd:string.
:Bob :bingo "Bob Smith".
:Rob :bingo "Rob Smith"^^xsd:string.
#ENDS 0 [msec] TC=6 TP=12 BC=0 BP=7 PM=0 CM=0 FM=0 AM=0
TC=6 TP=12 BC=0 BP=7 PM=0 CM=0 FM=0 AM=0
reasoning 0 [msec cputime] 2 [msec walltime]

相关内容

  • 没有找到相关文章

最新更新