From 85ccfe912f1df11e6fe8008cab1a2c329843ba8c Mon Sep 17 00:00:00 2001 From: Lionel TAILHARDAT Date: Wed, 16 Feb 2022 09:00:01 +0100 Subject: [PATCH 1/7] gradle7+ dependencies syntax --- build.gradle | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index fa43e60..c53ecac 100644 --- a/build.gradle +++ b/build.gradle @@ -27,13 +27,14 @@ repositories { } dependencies { - compile 'xml-apis:xml-apis:1.4.01', - 'org.apache.jena:apache-jena-libs:3.6.0', + implementation 'xml-apis:xml-apis:1.4.01', + 'org.apache.jena:apache-jena-libs:4.4.0', 'com.moparisthebest:junidecode:0.1.1', 'edu.stanford.nlp:stanford-corenlp:3.6.0', 'edu.stanford.nlp:stanford-corenlp:3.6.0:models' - testCompile 'junit:junit:4.11' + testImplementation 'junit:junit:4.11' + } From 8281efda62b78854a7d34340283291e919be3ed7 Mon Sep 17 00:00:00 2001 From: Lionel TAILHARDAT Date: Wed, 16 Feb 2022 09:29:47 +0100 Subject: [PATCH 2/7] dependencies for removing the `SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".` warning --- build.gradle | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c53ecac..b0e75d2 100644 --- a/build.gradle +++ b/build.gradle @@ -31,10 +31,13 @@ dependencies { 'org.apache.jena:apache-jena-libs:4.4.0', 'com.moparisthebest:junidecode:0.1.1', 'edu.stanford.nlp:stanford-corenlp:3.6.0', - 'edu.stanford.nlp:stanford-corenlp:3.6.0:models' + 'edu.stanford.nlp:stanford-corenlp:3.6.0:models', + // https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl + 'org.apache.logging.log4j:log4j-slf4j-impl:2.17.1' testImplementation 'junit:junit:4.11' + } From 1bb39be0c94a4a55a5829e57b5102c625ab5084f Mon Sep 17 00:00:00 2001 From: Lionel TAILHARDAT Date: Wed, 16 Feb 2022 10:18:03 +0100 Subject: [PATCH 3/7] typo at `project.hasProperty` preventing argument passing (i.e. `java.lang.NullPointerException at org.doremus.string2vocabulary.VocabularyManager.main(VocabularyManager.java:263)` --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b0e75d2..624493f 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ dependencies { run { - if (projects.hasProperty('input')) + if (project.hasProperty('input')) args = [ '--map', project.property('map'), '--lang', project.property('lang'), From 094bccb1a4cd591e7c5f5e35647f0366ae46f80d Mon Sep 17 00:00:00 2001 From: Lionel TAILHARDAT Date: Wed, 16 Feb 2022 10:40:59 +0100 Subject: [PATCH 4/7] Args logging to stdin (TODO: use log4j) --- .../java/org/doremus/string2vocabulary/VocabularyManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/doremus/string2vocabulary/VocabularyManager.java b/src/main/java/org/doremus/string2vocabulary/VocabularyManager.java index 0d5c6d0..e932bfd 100644 --- a/src/main/java/org/doremus/string2vocabulary/VocabularyManager.java +++ b/src/main/java/org/doremus/string2vocabulary/VocabularyManager.java @@ -262,6 +262,8 @@ public static void main(String args[]) throws IOException { String output = getParam(params, "--output"); if (output == null) output = input.replace(".ttl", "_output.ttl"); String lang = getParam(params, "--lang"); + System.out.println("Config:map='" + property2family + "':input='" + input + "':vocabularies='" + vocabularyFolder + "':output='" + output + "':lang='" + lang + "'."); + Model mi = RDFDataMgr.loadModel(input); VocabularyManager.run(property2family, vocabularyFolder, mi, output, lang); From cb48ef41d001491e1e948e1848101aed1a6e2a7c Mon Sep 17 00:00:00 2001 From: Lionel TAILHARDAT Date: Wed, 16 Feb 2022 10:41:29 +0100 Subject: [PATCH 5/7] log4j properties for future use --- src/main/resources/log4j.properties | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/resources/log4j.properties diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties new file mode 100644 index 0000000..3d582bd --- /dev/null +++ b/src/main/resources/log4j.properties @@ -0,0 +1,10 @@ +# Define the root logger with appender file +log4j.rootLogger = DEBUG, FILE + +# Define the file appender +log4j.appender.FILE=org.apache.log4j.FileAppender +log4j.appender.FILE.File=${log}/log.out + +# Define the layout for file appender +log4j.appender.FILE.layout=org.apache.log4j.PatternLayout +log4j.appender.FILE.layout.conversionPattern=%m%n \ No newline at end of file From de7c843711d2861e0b7806e2a27493b64059e84e Mon Sep 17 00:00:00 2001 From: Lionel TAILHARDAT Date: Wed, 16 Feb 2022 10:42:09 +0100 Subject: [PATCH 6/7] make use of gradle.properties for CLI run. --- .gitignore | 6 +++++- README.md | 29 +++++++++++++++++++++++++---- gradle.properties | 8 ++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 gradle.properties diff --git a/.gitignore b/.gitignore index a83753f..c9342f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ +# gradle workspace directory .gradle -# output directory +# build output directory build/ # eclim daemon conf file @@ -27,3 +28,6 @@ gradle-app.setting #intellij .idea *.iws + +# output example +output.ttl \ No newline at end of file diff --git a/README.md b/README.md index 9d6d16d..2a154f5 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,13 @@ ns:myMusicWork mus:U11_has_key ; - Normalise the labels by removing punctuation, decoding to ASCII, using lowercase - Search also for the singular version of the word with [Stanford CoreNLP](https://github.com/stanfordnlp/CoreNLP) -## As a module +Dependencies: +* Build tool: [Gradle](https://gradle.org/) 7+ +* See the `dependencies` section in the [build.gradle](build.gradle) file for project dependencies. + +## Usage + +### As a module 1. Add it as dependency. E.g. in `build.gradle`: @@ -103,11 +109,20 @@ VocabularyManager.string2uri(model) See the [test](src/test) folder for another example of usage. -## Command Line +### Command Line - gradle run -Pmap="/location/to/property2family.csv" -Pinput="/location/to/input.ttl" - -Pvocabularies="/location/to/vocabularyFolder" +Run the library from CLI with `gradle run`: +```shell +# Canonical form +gradle run -Pmap="/location/to/property2family.csv" \ + -Pinput="/location/to/input.ttl" \ + -Pvocabularies="/location/to/vocabularyFolder" +# Example with test files provided +gradle run -Pmap="src/test/resources/property2family.csv" \ + -Pinput="src/test/resources/input.ttl" \ + -Pvocabularies="src/test/resources/vocabulary" +``` | param | example | comment | | ----- | ------- | ------- | @@ -116,3 +131,9 @@ See the [test](src/test) folder for another example of usage. | input | `/location/to/input.ttl` | The input turtle file | | output _(Optional)_ | `/location/to/output.ttl` | The output turtle file. Default: `inputPath/inputName_output.ttl` | | lang _(Optional)_ | `fr` | Language to be used for singularising the words. Default: `en`. | + +Default `gradle run` behavior rely on *project properties* set in the [gradle.properties](gradle.properties) file. +See the following links for details about *properties* in Gradle: +* [Passing Command Line Arguments in Gradle](https://www.baeldung.com/gradle-command-line-arguments) +* [Gradle project properties best practices](https://tomgregory.com/gradle-project-properties-best-practices/) +* [Configuring Gradle with "gradle.properties" ](https://dev.to/jmfayard/configuring-gradle-with-gradle-properties-211k) \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..04f6788 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,8 @@ +## gradle.properties + +# Default run properties (test example) +map=src/test/resources/property2family.csv +lang=en +input=src/test/resources/input.ttl +output=output.ttl +vocabularies=src/test/resources/vocabulary \ No newline at end of file From 24d1683c41ae1e04184fefc1830fa0e8cf0e4fcc Mon Sep 17 00:00:00 2001 From: Lionel TAILHARDAT Date: Wed, 16 Feb 2022 10:43:27 +0100 Subject: [PATCH 7/7] Release number change --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 624493f..c3c0059 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'org.doremus' -version '0.6.0' +version '0.6.1' apply plugin: 'java' apply plugin: 'application'