Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions opennlp-uima/src/test/java/opennlp/uima/AbstractUimaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,19 @@ private void adaptModelURL(ResourceSpecifier specifier) {
for (ExternalResourceDescription modelDesc : resources) {
ResourceSpecifier resourceSpec = modelDesc.getResourceSpecifier();
String genericValue = resourceSpec.getAttributeValue(FILE_URL).toString();
String modelName = genericValue.split(":")[1]; // always right of 'file:' -> idx 1
final boolean isDictionary = genericValue.endsWith(".dic");
String resourceName;
if (genericValue != null && !isDictionary) {
resourceName = genericValue.split(":")[1]; // always right of 'file:' -> idx 1
} else {
resourceName = genericValue;
}
try {
if ("dictionary.dic".equals(modelName)) {
URL fileURL = Paths.get(TARGET_DIR, modelName).toUri().toURL();
if (isDictionary) {
URL fileURL = Paths.get(TARGET_DIR, resourceName).toUri().toURL();
resourceSpec.setAttributeValue(FILE_URL, fileURL.toExternalForm());
} else {
URL modelURL = OPENNLP_DIR.resolve(modelName).toUri().toURL();
URL modelURL = OPENNLP_DIR.resolve(resourceName).toUri().toURL();
resourceSpec.setAttributeValue(FILE_URL, modelURL.toExternalForm());
}
} catch (MalformedURLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import opennlp.uima.AbstractTest;
import opennlp.uima.util.CasUtil;

import static org.junit.jupiter.api.Assertions.assertNotNull;

public class DictionaryResourceTest extends AbstractTest {

private static AnalysisEngine AE;
Expand All @@ -54,15 +56,17 @@ public static void beforeClass() throws Exception {

@AfterAll
public static void afterClass() {
AE.destroy(); // is this necessary?
if (AE != null) {
AE.destroy(); // is this necessary?
}
}

private static AnalysisEngine produceAE(String descName)
throws IOException, InvalidXMLException, ResourceInitializationException {
File descFile = new File(PATH_DESCRIPTORS + "/" + descName);
XMLInputSource in = new XMLInputSource(descFile);
ResourceSpecifier specifier = UIMAFramework.getXMLParser()
.parseResourceSpecifier(in);
ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
assertNotNull(specifier);
return UIMAFramework.produceAnalysisEngine(specifier);
}

Expand All @@ -73,7 +77,7 @@ public void testDictionaryWasLoaded() {
final DictionaryResource dic = (DictionaryResource) AE.getResourceManager()
.getResource("/opennlp.uima.Dictionary");
final Dictionary d = dic.getDictionary();
Assertions.assertNotNull(d);
assertNotNull(d);
Assertions.assertEquals(6, d.asStringSet().size(),
"There should be six entries in the dictionary");
Assertions.assertTrue(d.contains(new StringList("London")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<name>NameFinderDictionary</name>
<description/>
<fileResourceSpecifier>
<fileUrl>file:dictionary.dic</fileUrl>
<fileUrl>dictionary.dic</fileUrl>
</fileResourceSpecifier>
<implementationName>opennlp.uima.dictionary.DictionaryResourceImpl</implementationName>
</externalResource>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
<!-- Dependency versions -->
<junit.version>5.13.4</junit.version>
<junit5-system-exit.version>2.0.2</junit5-system-exit.version>
<uimaj.version>3.6.0</uimaj.version>
<uimaj.version>3.6.1</uimaj.version>
<morfologik.version>2.1.9</morfologik.version>
<onnxruntime.version>1.23.0</onnxruntime.version>
<slf4j.version>2.0.17</slf4j.version>
Expand Down