Skip to content

Commit

Permalink
Merge pull request #5 from GenEars/master
Browse files Browse the repository at this point in the history
Gradle 7+ compatibility
  • Loading branch information
pasqLisena authored Feb 16, 2022
2 parents 3116e06 + 24d1683 commit 9836b9c
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# gradle workspace directory
.gradle

# output directory
# build output directory
build/

# eclim daemon conf file
Expand All @@ -27,3 +28,6 @@ gradle-app.setting
#intellij
.idea
*.iws

# output example
output.ttl
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ ns:myMusicWork mus:U11_has_key <http://data.doremus.org/vocabulary/key/d> ;
- 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`:

Expand Down Expand Up @@ -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 |
| ----- | ------- | ------- |
Expand All @@ -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)
16 changes: 10 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'org.doremus'
version '0.6.0'
version '0.6.1'

apply plugin: 'java'
apply plugin: 'application'
Expand Down Expand Up @@ -27,18 +27,22 @@ 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'
'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'


testCompile 'junit:junit:4.11'
}


run {
if (projects.hasProperty('input'))
if (project.hasProperty('input'))
args = [
'--map', project.property('map'),
'--lang', project.property('lang'),
Expand Down
8 changes: 8 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9836b9c

Please sign in to comment.