imas / rdflint Goto Github PK
View Code? Open in Web Editor NEWRDF linter
Home Page: https://imas.github.io/rdflint/
License: MIT License
RDF linter
Home Page: https://imas.github.io/rdflint/
License: MIT License
Support rdflint-config.yml at default path only.
default path is following.
Support rdflint-config.yml at custom path.
TODO:
Add custom configuration path to vscode settings.
and start language server with rdflint-config.yml at custom path.
rdflint/src/main/java/com/github/imas/rdflint/RdfLint.java
Lines 347 to 353 in e5db74a
QueryExecution#execSelect()
は DESCRIBE が実行できずにエラーが投げられます。
Query#getQueryType()
でクエリタイプを取得して分岐し、 QueryExecution#execDescribe()
を実行するのがいいかと思います(返り値も異なります)。
rdflint-problems.yml の出力先ディレクトリを指定できる設定項目がほしいです。
validation/undefinedSubject[]/url で指定したURLからデータを取得できないときに
RiotNotFoundExceptionが発生して異常終了する。
設定例: rdflint-config.yml
validation:
undefinedSubject:
- url: https://www.w3.org/2002/07/owl
startswith: http://www.w3.org/2002/07/owl#
langtype: turtle
発生エラー:
Exception in thread "main" org.apache.jena.riot.RiotNotFoundException: Not found: https://www.w3.org/2002/07/owlx
at org.apache.jena.riot.RDFParser.openTypedInputStream(RDFParser.java:394)
at org.apache.jena.riot.RDFParser.parseURI(RDFParser.java:301)
at org.apache.jena.riot.RDFParser.parse(RDFParser.java:295)
at org.apache.jena.riot.RDFParser.parse(RDFParser.java:237)
at org.apache.jena.riot.RDFParserBuilder.parse(RDFParserBuilder.java:518)
at com.github.imas.rdflint.validator.impl.UndefinedSubjectValidator.loadSubjects(UndefinedSubjectValidator.java:89)
at com.github.imas.rdflint.validator.impl.UndefinedSubjectValidator.setParameters(UndefinedSubjectValidator.java:79)
at com.github.imas.rdflint.ValidationRunner.lambda$execute$2(ValidationRunner.java:70)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at com.github.imas.rdflint.ValidationRunner.execute(ValidationRunner.java:69)
at com.github.imas.rdflint.RdfLint.lintRdfDataSet(RdfLint.java:223)
at com.github.imas.rdflint.RdfLint.main(RdfLint.java:140)
現状のメッセージは汎用的な内容なので、
その制約がある背景なども分かるように、対応するShapeのコメントを出力するとわかりやすいと思われる。
(im@sparqlの場合、Shapeのrdfs:comment,rdfs:labelに説明があるので)
現状のメッセージの例
SHACLで定義された制約に違反しています: "Value has 2 shapes out of 2 in the sh:xone enumeration" (http://www.w3.org/ns/shacl#XoneConstraintComponent) (line: 37, col: 1, triple: https://sparql.crssnky.xyz/imasrdf/RDFs/detail/Amami_Haruka - http://xmlns.com/foaf/0.1/age - "-17"^^http://www.w3.org/2001/XMLSchema#integer)
対応するShape
imas-shape:IdolShape a sh:NodeShape;
sh:targetClass imas:Idol;
sh:property [
rdfs:label "年齢の制約";
rdfs:comment "何人かのアイドルは年齢が数値じゃない";
sh:path foaf:age;
sh:xone (
[
sh:datatype xsd:integer;
sh:minInclusive 0;
]
[
sh:datatype rdf:langString;
sh:languageIn ("ja")
]
);
sh:maxCount 1;
];
エラー・警告メッセージは、日本語に対応するためにリソースファイルに出したい
手元に0.1.3を持ってきて、-config Unit_memberOf.yml
するとnoctchillのメンバーからの逆参照が生成されるが、GitHubActionsで動かしてる方は生成されていない(いつからうまく機能していないかはわからない)
記載する予定の内容
作業branch
https://github.com/takemikami/rdflint/tree/docs-draft/docs
以下のようなケースでNullPointerExceptionとなるので、
Shapeの構文エラーであることがわかるようにしたい。
例: sh:pathとすべきところが、sh:passとなっている
imas-shape:IdolShape a sh:NodeShape;
sh:targetClass imas:Idol;
sh:property [
rdfs:label "アイドルの登場するコンテンツのタイトルの制約";
sh:pass imas:Title;
sh:datatype rdf:langString;
sh:minCount 1;
];
発生するエラー
Exception in thread "main" java.lang.NullPointerException
at org.topbraid.shacl.validation.java.ClosedConstraintExecutor.<init>(ClosedConstraintExecutor.java:34)
at org.topbraid.shacl.validation.java.JavaConstraintExecutors.lambda$static$2(JavaConstraintExecutors.java:20)
at org.topbraid.shacl.validation.ConstraintExecutors.getExecutor(ConstraintExecutors.java:81)
at org.topbraid.shacl.engine.Constraint.getExecutor(Constraint.java:98)
at org.topbraid.shacl.validation.ValidationEngine.validateNodesAgainstConstraint(ValidationEngine.java:488)
at org.topbraid.shacl.validation.ValidationEngine.validateAll(ValidationEngine.java:368)
at org.topbraid.shacl.validation.ValidationUtil.validateModel(ValidationUtil.java:121)
at org.topbraid.shacl.validation.ValidationUtil.validateModel(ValidationUtil.java:102)
at com.github.imas.rdflint.validator.impl.ShaclValidator.prepareValidationResource(ShaclValidator.java:41)
at com.github.imas.rdflint.ValidationRunner.lambda$execute$6(ValidationRunner.java:93)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at com.github.imas.rdflint.ValidationRunner.execute(ValidationRunner.java:92)
at com.github.imas.rdflint.RdfLint.lintRdfDataSet(RdfLint.java:201)
at com.github.imas.rdflint.RdfLint.main(RdfLint.java:116)
Hi, maybe I am still confused what this linter is supposed to do, but I thought it would show me errors in ttl files. I just inserted an invalid ttl file to test and as a result I get a NullPointerException and there seems no way to actually find the incorrect ttl file in the log.
https://github.com/dbpedia/format-mappings/runs/554543342?check_suite_focus=true
Run rdflint
rdflint
shell: /bin/bash -e {0}
env:
JAVA_HOME: /opt/hostedtoolcache/jdk/11.0.6/x64
JAVA_HOME_11.0.6_x64: /opt/hostedtoolcache/jdk/11.0.6/x64
Exception in thread "main" java.lang.NullPointerException
at org.apache.jena.riot.system.RiotLib.isBNodeIRI(RiotLib.java:86)
at org.apache.jena.riot.system.ParserProfileStd.createURI(ParserProfileStd.java:152)
at org.apache.jena.riot.system.ParserProfileStd.create(ParserProfileStd.java:216)
at org.apache.jena.riot.lang.LangTurtleBase.tokenAsNode(LangTurtleBase.java:498)
at org.apache.jena.riot.lang.LangTurtleBase.node(LangTurtleBase.java:343)
at org.apache.jena.riot.lang.LangTurtleBase.triples(LangTurtleBase.java:245)
at org.apache.jena.riot.lang.LangTurtleBase.triplesSameSubject(LangTurtleBase.java:191)
at org.apache.jena.riot.lang.LangTurtle.oneTopLevelElement(LangTurtle.java:46)
at org.apache.jena.riot.lang.LangTurtleBase.runParser(LangTurtleBase.java:91)
at org.apache.jena.riot.lang.LangBase.parse(LangBase.java:41)
at org.apache.jena.riot.RDFParserRegistry$ReaderRIOTLang.read(RDFParserRegistry.java:191)
at org.apache.jena.riot.RDFParser.read(RDFParser.java:352)
at org.apache.jena.riot.RDFParser.parseURI(RDFParser.java:321)
at org.apache.jena.riot.RDFParser.parse(RDFParser.java:295)
at org.apache.jena.riot.RDFParser.parse(RDFParser.java:237)
at com.github.imas.rdflint.validator.impl.RdfSyntaxValidator.validateFile(RdfSyntaxValidator.java:65)
at com.github.imas.rdflint.ValidationRunner.lambda$null$4(ValidationRunner.java:77)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at com.github.imas.rdflint.ValidationRunner.lambda$execute$5(ValidationRunner.java:77)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
vscode-rdflintがmacOS上ではある程度動作しているが、
Windows環境ではかなり怪しい挙動が多いため。
このissueで見つけた不具合を列挙して、対処を進めていく。
不具合リスト(随時更新):
NoClassDefFoundError
エラー
rdflintの最新versionは以下で取得可能なので、circleciのcronjobとかで対応は可能と考えられる
$ curl -s https://jitpack.io/api/builds/com.github.imas/rdflint/latestOk | jq -r '.version'
0.0.9
see. https://jitpack.io/docs/API/#latest-build
導入しているリポジトリ側で対応して貰う想定で、
設定方法のドキュメント、スクリプト提供などを検討する。
seems not to work an returns strange warnings
https://github.com/dbpedia/format-mappings/runs/477652228?check_suite_focus=true
Run rdflint3s
##[error]Process completed with exit code 1.
Run rdflint
tarql/1.ttl
ERROR RDF parse warning: [line: 1, col: 1] null
tarql/2.ttl
ERROR RDF parse warning: [line: 1, col: 1] null
tarql/3.ttl
ERROR RDF parse warning: [line: 1, col: 1] null
##[error]Process completed with exit code 1.
クエリ本文中でのプレフィックスの補完
たとえば WHERE 文中で ?s sch で ?s schema: が補完できるといいかなと思いました。
see. #62 (comment)
Visual Studio Codeでの検証結果表示を想定した、
Language Server Protocol による検証処理の実装
Language Server Protocol
https://microsoft.github.io/language-server-protocol/
Language Server Extension Guide | Visual Studio Code
https://code.visualstudio.com/api/language-extensions/language-server-extension-guide
LSP4JでLanguage Server Protocol入門
https://qiita.com/minebreaker/items/c53e4dddb0709492d362
初めまして。有益なツールの提供をどうもありがとうございます。
ところで、SHACL制約の与え方について、ドキュメントを読んだ限りでは分かりませんでしたので、追加していただけますか?
データ型チェック・外れ値チェックは統計的に出しているので、必ず誤りと扱うことは出来ないので、除外設定できるようにしたい
使用する・しないvalidatorを指定もできるようにしたい
例えば以下のものなど、まずは候補上げるところから。
警告文で表示されるURIに /undefined
というパスがくっついてしまいます.
baseUri
の後ろに /undefined
が入っているように感じます.
警告文の例
WARN Undefined URI: https://prismdb.takanakahiko.me/undefined/prism-schema.ttl#member (triple: https://prismdb.takanakahiko.me/undefined/rdfs/team/tricolore - https://prismdb.takanakahiko.me/undefined/prism-schema.ttl#member - https://prismdb.takanakahiko.me/undefined/rdfs/character/midorikaze_fuwari)
この場合,例えば https://prismdb.takanakahiko.me/undefined/rdfs/team/tricolore
は,本来は https://prismdb.takanakahiko.me/rdfs/team/tricolore
です.
確認できる場所 : https://github.com/prickathon/prismdb/runs/251908036
rdflintの設定ファイルについて、
rdflint-config.yml以外にも、
generationのテンプレートなどが存在するケースがあるので、
標準的な配置ディレクトリを決め、rdflint-config.ymlの探索パスに加えたい。
現状の探索パス:
追加する探索パス:
SHACL制約「Value must be an instance of」のエラーで指摘箇所が正しくない場合がある。
実際にim@sparqlで発生した問題と、期待結果を示す。
発生エラー:
RDFs/Clothes.rdf
WARN SHACL violation: (https://sparql.crssnky.xyz/imasrdf/RDFs/detail/Glory_Monochrome_Another2 @https://sparql.crssnky.xyz/imasrdf/URIs/imas-schema.ttl#Whose https://sparql.crssnky.xyz/imasrdf/RDFs/detail/Watanabe_Minori) "Value must be an instance of <https://sparql.crssnky.xyz/imasrdf/URIs/imas-schema.ttl#Idol>" (http://www.w3.org/ns/shacl#ClassConstraintComponent) (triple: https://sparql.crssnky.xyz/imasrdf/RDFs/detail/Glory_Monochrome_Another2 - https://sparql.crssnky.xyz/imasrdf/URIs/imas-schema.ttl#Whose - https://sparql.crssnky.xyz/imasrdf/RDFs/detail/Watanabe_Minori)
制約:
データの状態:
発生しているエラー:
期待されるエラー:
読み込んだ RDF 中のプレフィックスの補完
PREFIX_MAP を固定で持っていますが、読み込んだ RDF に記述されているプレフィックスも補完できるようになると更に便利になるなと思いました。
チラッと見てみたところ、loadRdfSet() で parse した Graph は、getPrefixMapping() を呼ぶことでプレフィックスを取れるようです。
see. #62 (comment)
rdflint-config.yml
にて、
trim_trailing_whitespace: true
となっている時、一部の行末がspaceで終わっていると
WARN Need trailing white space
と表示され、行末の空白を要求される。
95% of following explanation.
Literal Value of Same predicate judge string, real number, integer or natual number.
Data type of 95% over data is valid type of prediate.
3 of following explanation.
when a distance between last combined cluster is less 3times of before combined distance, jedge is ok.
[Error - 12:30:00 AM] Starting client failed
Error: spawn ENOTDIR
at ChildProcess.spawn (internal/child_process.js:407:11)
at Object.spawn (child_process.js:548:9)
at /home/<UserName>/.vscode-server/extensions/takemikami.vscode-rdflint-0.1.4/node_modules/vscode-languageclient/lib/main.js:354:40
(Linuxユーザー名はに変更しています)
また、関係があるかは不明ですが、インタラクティブモードをCtrl+Shift+Pから起動しようとすると
ターミナル プロセス "/usr/lib/jvm/java-11-openjdk-amd64/bin/java/bin/java '-jar', '/home/<UserName>/.vscode-server/extensions/takemikami.vscode-rdflint-0.1.4/rdflint-0.1.4.jar', '-i'" が起動に失敗しました (終了コード: 1)。
と、vscodeのデスクトップ通知が出て起動しません。
(自前でjava -jar <rdflintのパス> -i
をTerminalで打つと起動します)
rdflint's java version upgrade to 11 or newer, becase latest jena require java11.
apache/jena@55aa735
default jdk version of jitpack is java8, and setup jdk along following document.
see. https://jitpack.io/docs/BUILDING/#java-version
Hello,
I get an internal error whilst using the extension, but I can not find any log/description of the issue. No syntax highlight is seem.
Could anyone help?
Thank you very much
現状、設定ファイルに「baseUri」を指定していない場合は、
未定義主語のチェックを行わない仕様となっている。
(baseUriで始まるURIが、データセット内に定義されているべきと言う前提で、未定義主語チェックが走る)
#65 で加えたschema.org等の一般的なスキーマの場合は、定義範囲の前提が不要なので、
schema.org等の未定義主語チェックは、baseUriを指定していなくてもチェックすべきと考えられる。
rdflint で使用している Groovy 2.5.4 を Java 11 で動かすと発生する WARNING のようですね?
これかな。3.0.0-beta-1 で直ってるみたいですけど最新版が未だ 3.0.0-rc-3 ですね・・・
https://issues.apache.org/jira/browse/GROOVY-8339
Run rdflint -config .rdflint/rdflint-config.yml
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/opt/hostedtoolcache/rdflint/0.1.2/x64/rdflint.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
パス関連のコマンドラインパラメータ・設定ファイル項目を整理したい。
im@sparqlのパスを前提に開発をしてきたので、
データセットがリポジトリ直下に無い場合の挙動が分かりにくい。
リポジトリの例:
(im@sparqlなどの場合)
(prismdbなどの場合)
コマンドラインのパラメータにリポジトリルートを指定出来るようにして、
cdで移動して実行した場合と、パラメータで指定した場合
それぞれの挙動を一致させるのが好ましいと考えている。
cd リポジトリルート
java -jar rdflint-0.0.9-all.jar
java -jar rdflint-0.0.9-all.jar -パス指定 リポジトリルート
Interactive mode do not work on macos with coreutils, and display following error.
This problem will fix after merge the pull request jline/jline3#706 .
generation処理のみ(generation処理の一部のみも)を実行できるように実行パラメータを追加する
背景として、
imasparqlではgenerationのみをおこなうために、複数の設定を作っているため、
その複雑さを解消したい。
以下のコマンドラインオプションと設定ファイル項目がドキュメントに記載されていません。
suppressPath
Interactive Mode で入力するクエリの BASE と PREFIX について、読み込んだ RDF ファイルに記述されているものを省略できる機能を提案します(筋が悪いでしょうか?)。
PREFIX については、 org.apache.jena.graph.Graph#getPrefixMapping()
が使えるかもしれません。
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 として扱われること。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.