imas/rdflint

DataTypeValidator で decimal な値が NATURAL として扱われる場合がある

Closed this issue · 1 comments

BASE <http://example.com/>
PREFIX : <http://schema.org/>

<a> :height 160.0 .
<b> :height 160.0 .
<c> :height 160.0 .
<d> :height 160.0 .
<e> :height 160.0 .
<f> :height 160.0 .
<g> :height 160.0 .
<h> :height 160.0 .
<i> :height 160.0 .
<j> :height 160.0 .
<k> :height 160.0 .
<l> :height 160.0 .
<m> :height 160.0 .
<n> :height 160.0 .
<o> :height 160.0 .
<p> :height 160.0 .
<q> :height 160.0 .
<r> :height 160.0 .
<s> :height 160.0 .
<t> :height 160.0 .
<u> :height 160.0 .
<v> :height 160.0 .
<w> :height 160.0 .
<x> :height 160.0 .
<y> :height 160.0 .
<z> :height 160.0 .
<error> :height 160.1 .
$ rdflint
example.ttl
  INFO  データ型が揃っていません: NATURALが予測されましたがFLOATです (triple: http://example.com/error - http://schema.org/height - "160.1"^^http://www.w3.org/2001/XMLSchema#decimal)

Expected Behavior: 160.0 のような値が FLOAT として扱われること。

RDF において decimal な値でも getLiteralValue() が Integer を返してしまうようです。代わりに getLiteralLexicalForm() を使うことを提案します。

.map(t -> DataTypeUtils.guessDataType(t.getObject().getLiteralValue().toString()))

"160.0"^^http://www.w3.org/2001/XMLSchema#decimal → getLiteralValue() → 160 (Integer)
"160.0"^^http://www.w3.org/2001/XMLSchema#decimal → getLiteralLexicalForm() → 160.0 (String)