You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jz...@apache.org on 2022/04/11 11:44:04 UTC

[opennlp] branch master updated: OPENNLP-1351: Moving onnx models for testing. Fixing expected value. (#410)

This is an automated email from the ASF dual-hosted git repository.

jzemerick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/opennlp.git


The following commit(s) were added to refs/heads/master by this push:
     new c8655591 OPENNLP-1351: Moving onnx models for testing. Fixing expected value. (#410)
c8655591 is described below

commit c8655591e3233f186261d4e8ba12ff1fdedb83b3
Author: Jeff Zemerick <je...@mtnfog.com>
AuthorDate: Mon Apr 11 04:43:58 2022 -0700

    OPENNLP-1351: Moving onnx models for testing. Fixing expected value. (#410)
---
 .../src/test/java/opennlp/dl/AbstactDLTest.java    |  2 +-
 .../dl/doccat/DocumentCategorizerDLEval.java       | 16 ++++++-------
 .../opennlp/dl/namefinder/NameFinderDLEval.java    | 26 +++++++++++-----------
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/opennlp-dl/src/test/java/opennlp/dl/AbstactDLTest.java b/opennlp-dl/src/test/java/opennlp/dl/AbstactDLTest.java
index 09e0c591..f3d4b18d 100644
--- a/opennlp-dl/src/test/java/opennlp/dl/AbstactDLTest.java
+++ b/opennlp-dl/src/test/java/opennlp/dl/AbstactDLTest.java
@@ -29,7 +29,7 @@ public abstract class AbstactDLTest {
     if (StringUtil.isEmpty(dataDirectory)) {
       throw new IllegalArgumentException("The OPENNLP_DATA_DIR is not set.");
     }
-    final File file = new File(System.getProperty("OPENNLP_DATA_DIR"));
+    final File file = new File(dataDirectory);
     if (!file.exists()) {
       throw new FileNotFoundException("The OPENNLP_DATA_DIR path of " + dataDirectory + " was not found.");
     }
diff --git a/opennlp-dl/src/test/java/opennlp/dl/doccat/DocumentCategorizerDLEval.java b/opennlp-dl/src/test/java/opennlp/dl/doccat/DocumentCategorizerDLEval.java
index d82373a8..7d76774c 100644
--- a/opennlp-dl/src/test/java/opennlp/dl/doccat/DocumentCategorizerDLEval.java
+++ b/opennlp-dl/src/test/java/opennlp/dl/doccat/DocumentCategorizerDLEval.java
@@ -37,8 +37,8 @@ public class DocumentCategorizerDLEval extends AbstactDLTest {
     // This test was written using the nlptown/bert-base-multilingual-uncased-sentiment model.
     // You will need to update the assertions if you use a different model.
 
-    final File model = new File(getOpennlpDataDir(), "dl-doccat/model.onnx");
-    final File vocab = new File(getOpennlpDataDir(), "dl-doccat/vocab.txt");
+    final File model = new File(getOpennlpDataDir(), "onnx/doccat/model.onnx");
+    final File vocab = new File(getOpennlpDataDir(), "onnx/doccat/vocab.txt");
 
     final DocumentCategorizerDL documentCategorizerDL =
             new DocumentCategorizerDL(model, vocab, getCategories());
@@ -67,8 +67,8 @@ public class DocumentCategorizerDLEval extends AbstactDLTest {
     // This test was written using the nlptown/bert-base-multilingual-uncased-sentiment model.
     // You will need to update the assertions if you use a different model.
 
-    final File model = new File(getOpennlpDataDir(), "dl-doccat/model.onnx");
-    final File vocab = new File(getOpennlpDataDir(), "dl-doccat/vocab.txt");
+    final File model = new File(getOpennlpDataDir(), "onnx/doccat/model.onnx");
+    final File vocab = new File(getOpennlpDataDir(), "onnx/doccat/vocab.txt");
 
     final DocumentCategorizerDL documentCategorizerDL =
             new DocumentCategorizerDL(model, vocab, getCategories());
@@ -89,8 +89,8 @@ public class DocumentCategorizerDLEval extends AbstactDLTest {
     // This test was written using the nlptown/bert-base-multilingual-uncased-sentiment model.
     // You will need to update the assertions if you use a different model.
 
-    final File model = new File(getOpennlpDataDir(), "dl-doccat/model.onnx");
-    final File vocab = new File(getOpennlpDataDir(), "dl-doccat/vocab.txt");
+    final File model = new File(getOpennlpDataDir(), "onnx/doccat/model.onnx");
+    final File vocab = new File(getOpennlpDataDir(), "onnx/doccat/vocab.txt");
 
     final DocumentCategorizerDL documentCategorizerDL =
             new DocumentCategorizerDL(model, vocab, getCategories());
@@ -111,8 +111,8 @@ public class DocumentCategorizerDLEval extends AbstactDLTest {
     // This test was written using the nlptown/bert-base-multilingual-uncased-sentiment model.
     // You will need to update the assertions if you use a different model.
 
-    final File model = new File(getOpennlpDataDir(), "dl-doccat/model.onnx");
-    final File vocab = new File(getOpennlpDataDir(), "dl-doccat/vocab.txt");
+    final File model = new File(getOpennlpDataDir(), "onnx/doccat/model.onnx");
+    final File vocab = new File(getOpennlpDataDir(), "onnx/doccat/vocab.txt");
 
     final DocumentCategorizerDL documentCategorizerDL =
             new DocumentCategorizerDL(model, vocab, getCategories());
diff --git a/opennlp-dl/src/test/java/opennlp/dl/namefinder/NameFinderDLEval.java b/opennlp-dl/src/test/java/opennlp/dl/namefinder/NameFinderDLEval.java
index f5eef935..86c4a7b8 100644
--- a/opennlp-dl/src/test/java/opennlp/dl/namefinder/NameFinderDLEval.java
+++ b/opennlp-dl/src/test/java/opennlp/dl/namefinder/NameFinderDLEval.java
@@ -38,8 +38,8 @@ public class NameFinderDLEval extends AbstactDLTest {
     // This test was written using the dslim/bert-base-NER model.
     // You will need to update the ids2Labels and assertions if you use a different model.
 
-    final File model = new File(getOpennlpDataDir(), "namefinder/model.onnx");
-    final File vocab = new File(getOpennlpDataDir(), "namefinder/vocab.txt");
+    final File model = new File(getOpennlpDataDir(), "onnx/namefinder/model.onnx");
+    final File vocab = new File(getOpennlpDataDir(), "onnx/namefinder/vocab.txt");
 
     final String[] tokens = new String[]
         {"George", "Washington", "was", "president", "of", "the", "United", "States", "."};
@@ -54,7 +54,7 @@ public class NameFinderDLEval extends AbstactDLTest {
     Assert.assertEquals(1, spans.length);
     Assert.assertEquals(0, spans[0].getStart());
     Assert.assertEquals(2, spans[0].getEnd());
-    Assert.assertEquals(0.8251646041870118, spans[0].getProb(), 0.0);
+    Assert.assertEquals(8.251646041870117, spans[0].getProb(), 0.0);
 
   }
 
@@ -64,8 +64,8 @@ public class NameFinderDLEval extends AbstactDLTest {
     // This test was written using the dslim/bert-base-NER model.
     // You will need to update the ids2Labels and assertions if you use a different model.
 
-    final File model = new File(getOpennlpDataDir(), "namefinder/model.onnx");
-    final File vocab = new File(getOpennlpDataDir(), "namefinder/vocab.txt");
+    final File model = new File(getOpennlpDataDir(), "onnx/namefinder/model.onnx");
+    final File vocab = new File(getOpennlpDataDir(), "onnx/namefinder/vocab.txt");
 
     final String[] tokens = new String[]{"His", "name", "was", "George", "Washington"};
 
@@ -88,8 +88,8 @@ public class NameFinderDLEval extends AbstactDLTest {
     // This test was written using the dslim/bert-base-NER model.
     // You will need to update the ids2Labels and assertions if you use a different model.
 
-    final File model = new File(getOpennlpDataDir(), "namefinder/model.onnx");
-    final File vocab = new File(getOpennlpDataDir(), "namefinder/vocab.txt");
+    final File model = new File(getOpennlpDataDir(), "onnx/namefinder/model.onnx");
+    final File vocab = new File(getOpennlpDataDir(), "onnx/namefinder/vocab.txt");
 
     final String[] tokens = new String[]{"His", "name", "was", "George"};
 
@@ -112,8 +112,8 @@ public class NameFinderDLEval extends AbstactDLTest {
     // This test was written using the dslim/bert-base-NER model.
     // You will need to update the ids2Labels and assertions if you use a different model.
 
-    final File model = new File(getOpennlpDataDir(), "namefinder/model.onnx");
-    final File vocab = new File(getOpennlpDataDir(), "namefinder/vocab.txt");
+    final File model = new File(getOpennlpDataDir(), "onnx/namefinder/model.onnx");
+    final File vocab = new File(getOpennlpDataDir(), "onnx/namefinder/vocab.txt");
 
     final String[] tokens = new String[]{};
 
@@ -130,8 +130,8 @@ public class NameFinderDLEval extends AbstactDLTest {
     // This test was written using the dslim/bert-base-NER model.
     // You will need to update the ids2Labels and assertions if you use a different model.
 
-    final File model = new File(getOpennlpDataDir(), "namefinder/model.onnx");
-    final File vocab = new File(getOpennlpDataDir(), "namefinder/vocab.txt");
+    final File model = new File(getOpennlpDataDir(), "onnx/namefinder/model.onnx");
+    final File vocab = new File(getOpennlpDataDir(), "onnx/namefinder/vocab.txt");
 
     final String[] tokens = new String[]{"I", "went", "to", "the", "park"};
 
@@ -148,8 +148,8 @@ public class NameFinderDLEval extends AbstactDLTest {
     // This test was written using the dslim/bert-base-NER model.
     // You will need to update the ids2Labels and assertions if you use a different model.
 
-    final File model = new File(getOpennlpDataDir(), "namefinder/model.onnx");
-    final File vocab = new File(getOpennlpDataDir(), "namefinder/vocab.txt");
+    final File model = new File(getOpennlpDataDir(), "onnx/namefinder/model.onnx");
+    final File vocab = new File(getOpennlpDataDir(), "onnx/namefinder/vocab.txt");
 
     final String[] tokens = new String[]{"George", "Washington", "and", "Abraham", "Lincoln",
         "were", "presidents"};