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 f3f28b27 OPENNLP-1393: Updating doccat DL test due to OPENNLP-1374
(#430)
f3f28b27 is described below
commit f3f28b271d43a43958db1ef94d282d9c3100475a
Author: Jeff Zemerick <[email protected]>
AuthorDate: Mon Oct 31 16:09:42 2022 -0400
OPENNLP-1393: Updating doccat DL test due to OPENNLP-1374 (#430)
---
.../dl/doccat/DocumentCategorizerDLEval.java | 28 +++++++++++++---------
1 file changed, 17 insertions(+), 11 deletions(-)
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 26fa89dc..7977004c 100644
--- a/opennlp-dl/src/test/java/opennlp/dl/doccat/DocumentCategorizerDLEval.java
+++ b/opennlp-dl/src/test/java/opennlp/dl/doccat/DocumentCategorizerDLEval.java
@@ -20,6 +20,7 @@ package opennlp.dl.doccat;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -64,20 +65,26 @@ public class DocumentCategorizerDLEval extends
AbstactDLTest {
final double[] result = documentCategorizerDL.categorize(new
String[]{text});
- System.out.println(Arrays.toString(result));
+ // Sort the result for easier comparison.
+ final double[] sortedResult = Arrays.stream(result)
+ .boxed()
+
.sorted(Collections.reverseOrder()).mapToDouble(Double::doubleValue).toArray();
final double[] expected = new double[]
- {0.3655166029930115,
- 0.26701385776201886,
- 0.19334411124388376,
- 0.09859892477591832,
- 0.07552650570869446};
+ {0.3391093313694,
+ 0.2611352801322937,
+ 0.24420668184757233,
+ 0.11939861625432968,
+ 0.03615010157227516};
+
+ System.out.println("Actual: " + Arrays.toString(sortedResult));
+ System.out.println("Expected: " + Arrays.toString(expected));
- Assertions.assertTrue(Arrays.equals(expected, result));
+ Assertions.assertArrayEquals(expected, sortedResult, 0.0);
Assertions.assertEquals(5, result.length);
final String category = documentCategorizerDL.getBestCategory(result);
- Assertions.assertEquals("very bad", category);
+ Assertions.assertEquals("bad", category);
}
@@ -109,7 +116,7 @@ public class DocumentCategorizerDLEval extends
AbstactDLTest {
0.3003573715686798,
0.6352779865264893};
- Assertions.assertTrue(Arrays.equals(expected, result));
+ Assertions.assertArrayEquals(expected, result, 0.0);
Assertions.assertEquals(5, result.length);
final String category = documentCategorizerDL.getBestCategory(result);
@@ -138,11 +145,10 @@ public class DocumentCategorizerDLEval extends
AbstactDLTest {
inferenceOptions);
final double[] result = documentCategorizerDL.categorize(new String[]{"I
am angry"});
- System.out.println(Arrays.toString(result));
final double[] expected = new double[]{0.8851314783096313,
0.11486853659152985};
- Assertions.assertTrue(Arrays.equals(expected, result));
+ Assertions.assertArrayEquals(expected, result, 0.0);
Assertions.assertEquals(2, result.length);
final String category = documentCategorizerDL.getBestCategory(result);