Skip to content

Commit 7aa706a

Browse files
committed
fix opennlp version
additional debug messages version with git commit
1 parent b7914a5 commit 7aa706a

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

pipeline_config.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
def APP_NAME = "digator-opennlp"
22
def APP_REPO = "https://github.com/livelace/digator-opennlp.git"
33
def APP_VERSION = "${env.VERSION}-${env.OPENNLP_VERSION}"
4+
def JAR_VERSION = env.VERSION + '-${GIT_COMMIT_SHORT}-' + env.OPENNLP_VERSION
45

56

67
libraries {
@@ -29,12 +30,12 @@ libraries {
2930
options = "--build-arg OPENNLP_VERSION=${env.OPENNLP_VERSION}"
3031
}
3132
maven {
32-
options = "-Dquarkus.application.version=${APP_VERSION} -Dquarkus.package.type=uber-jar -Dopennlp.version=${env.OPENNLP_VERSION}"
33+
options = "-Dquarkus.application.version=${JAR_VERSION} -Dquarkus.package.type=uber-jar -Dopennlp.version=${env.OPENNLP_VERSION}"
3334
}
3435
mattermost
3536
nexus {
3637
source = "target/digator-opennlp-1.0-SNAPSHOT-runner.jar"
37-
destination = "dists-internal/${APP_NAME}/${APP_NAME}-${APP_VERSION}.jar"
38+
destination = "dists-internal/${APP_NAME}/${JAR_VERSION}.jar"
3839
}
3940
sonarqube
4041
utils

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
2020
<quarkus.platform.version>1.10.5.Final</quarkus.platform.version>
2121
<surefire-plugin.version>2.22.1</surefire-plugin.version>
22-
<opennlp.version>1.9.1</opennlp.version>
22+
<opennlp.version>1.8.4</opennlp.version>
2323
</properties>
2424

2525
<dependencyManagement>
@@ -72,7 +72,7 @@
7272
<dependency>
7373
<groupId>org.apache.opennlp</groupId>
7474
<artifactId>opennlp-tools</artifactId>
75-
<version>1.9.3</version>
75+
<version>${opennlp.version}</version>
7676
</dependency>
7777
</dependencies>
7878

src/main/java/ru/livelace/digator_opennlp/NerModel.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,16 @@ private JsonObject formatToLabelStudio(String text, String[] tokens, Span[] span
126126
* @param spans
127127
* @return
128128
*/
129-
private static String formatToOpennlp(String[] tokens, Span[] spans) {
129+
private String formatToOpennlp(String[] tokens, Span[] spans) {
130130
for (Span span: spans) {
131131
tokens[span.getStart()] = String.format("<START:%s> %s", span.getType(), tokens[span.getStart()]);
132132
tokens[span.getEnd()-1] = String.format("%s <END>", tokens[span.getEnd()-1]);
133133
}
134-
return String.join(" ", tokens);
134+
135+
var labeledString = String.join(" ", tokens);
136+
logger.debug("labeled text: \"{}\"", labeledString);
137+
138+
return labeledString;
135139
}
136140

137141
/**
@@ -153,8 +157,11 @@ public JsonObject label(String dataset, String lang, String type, String format,
153157
// Initialize model.
154158
if (models.get(modelSignature) == null) {
155159
try {
156-
models.put(modelSignature, new Model(dataset, lang, type));
157-
logger.debug("model has been loaded: {}/{}/{}/{}.bin", modelsPath, dataset, lang, type);
160+
var model = new Model(dataset, lang, type);
161+
models.put(modelSignature, model);
162+
logger.debug("model has been loaded: {}/{}/{}/{}.bin, {}, {}",
163+
modelsPath, dataset, lang, type, model.getVersion(), model.getLanguage());
164+
158165
} catch (Exception e) {
159166
logger.error("cannot load model: {}", e.getMessage());
160167
json.add(ERROR, e.getMessage());
@@ -221,8 +228,16 @@ public Span[] getLabel(String[] tokens) {
221228
return spans;
222229
}
223230

231+
public String getLanguage() {
232+
return opennlpModel.getLanguage();
233+
}
234+
224235
public String[] getTokens(String text) {
225236
return opennlpTokenizer.tokenize(text);
226237
}
238+
239+
public String getVersion() {
240+
return opennlpModel.getVersion().toString();
241+
}
227242
}
228243
}

0 commit comments

Comments
 (0)