[jira] [Commented] (OPENNLP-1590) Clear open TODO in GenericFactoryTest

2024-07-06 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/OPENNLP-1590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17863516#comment-17863516
 ] 

ASF GitHub Bot commented on OPENNLP-1590:
-

rzo1 commented on code in PR #633:
URL: https://github.com/apache/opennlp/pull/633#discussion_r1667397156


##
opennlp-tools/src/main/java/opennlp/tools/util/featuregen/DictionaryFeatureGeneratorFactory.java:
##
@@ -31,30 +33,39 @@
 public class DictionaryFeatureGeneratorFactory
 extends GeneratorFactory.AbstractXmlFeatureGeneratorFactory {
 
+  private static final String DICT = "dict";
+
   public DictionaryFeatureGeneratorFactory() {
 super();
   }
 
   @Override
   public AdaptiveFeatureGenerator create() throws InvalidFormatException {
-// if resourceManager is null, we don't instantiate
-if (resourceManager == null) {
-  return null;
-}
-
-String dictResourceKey = getStr("dict");
-Object dictResource = resourceManager.getResource(dictResourceKey);
-if (!(dictResource instanceof Dictionary)) {
-  throw new InvalidFormatException("No dictionary resource for key: " + 
dictResourceKey);
+Dictionary dict;
+if (resourceManager == null) { // load the dictionary directly
+  String dictResourcePath = getStr(DICT);
+  ClassLoader cl = Thread.currentThread().getContextClassLoader();
+  try (InputStream is = cl.getResourceAsStream(dictResourcePath)) {

Review Comment:
   `is` can be NULL after this call (if `dictResourcePath` isn't found). Didn't 
Look into create(...) how it is handled.



##
opennlp-tools/src/main/java/opennlp/tools/util/featuregen/DictionaryFeatureGeneratorFactory.java:
##
@@ -31,30 +33,39 @@
 public class DictionaryFeatureGeneratorFactory
 extends GeneratorFactory.AbstractXmlFeatureGeneratorFactory {
 
+  private static final String DICT = "dict";
+
   public DictionaryFeatureGeneratorFactory() {
 super();
   }
 
   @Override
   public AdaptiveFeatureGenerator create() throws InvalidFormatException {
-// if resourceManager is null, we don't instantiate
-if (resourceManager == null) {
-  return null;
-}
-
-String dictResourceKey = getStr("dict");
-Object dictResource = resourceManager.getResource(dictResourceKey);
-if (!(dictResource instanceof Dictionary)) {
-  throw new InvalidFormatException("No dictionary resource for key: " + 
dictResourceKey);
+Dictionary dict;
+if (resourceManager == null) { // load the dictionary directly
+  String dictResourcePath = getStr(DICT);
+  ClassLoader cl = Thread.currentThread().getContextClassLoader();
+  try (InputStream is = cl.getResourceAsStream(dictResourcePath)) {
+dict = ((DictionarySerializer) 
getArtifactSerializerMapping().get(dictResourcePath)).create(is);
+  } catch (IOException e) {
+throw new InvalidFormatException("No dictionary resource at: " + 
dictResourcePath, e);
+  }
+} else { // get the dictionary via a resourceManager lookup
+  String dictResourceKey = getStr(DICT);
+  Object dictResource = resourceManager.getResource(dictResourceKey);
+  if (dictResource instanceof Dictionary) {

Review Comment:
   Since we are Java 17, we can omit the cast in the subsequent line by inline 
casting in the instanceof.





> Clear open TODO in GenericFactoryTest
> -
>
> Key: OPENNLP-1590
> URL: https://issues.apache.org/jira/browse/OPENNLP-1590
> Project: OpenNLP
>  Issue Type: Test
>Affects Versions: 2.3.3
>Reporter: Martin Wiesner
>Assignee: Martin Wiesner
>Priority: Minor
> Fix For: 2.4.0
>
>
> The test case _testDictionaryArtifactToSerializerMappingExtraction()_ in 
> _GeneratorFactoryTest_ has a TODO note that can be cleared by adjusting the 
> test case slightly, as well as the related inconsistent implementation 
> class(es).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (OPENNLP-1590) Clear open TODO in GenericFactoryTest

2024-07-06 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/OPENNLP-1590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17863515#comment-17863515
 ] 

ASF GitHub Bot commented on OPENNLP-1590:
-

mawiesne opened a new pull request, #633:
URL: https://github.com/apache/opennlp/pull/633

   Change
   -
   - adjusts `DictionaryFeatureGeneratorFactory` to handle situations without a 
ResourceManager instance at runtime
   - fixes a missing Exception type in catch block of 
`GeneratorFactory#buildGenerator `which wasn't handled correctly
   - clears TODO in GeneratorFactoryTest
   - adds another test case to demonstrate that a descriptively declared 
dictionary is loaded for the creation of a `DictionaryFeatureGeneratorFactory`
   - adds a related test resource
   
   Tasks
   -
   Thank you for contributing to Apache OpenNLP.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [x] Is there a JIRA ticket associated with this PR? Is it referenced 
in the commit message?
   
   - [x] Does your PR title start with OPENNLP- where  is the JIRA 
number you are trying to resolve? Pay particular attention to the hyphen "-" 
character.
   
   - [x] Has your PR been rebased against the latest commit within the target 
branch (typically main)?
   
   - [x] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [x] Have you ensured that the full suite of tests is executed via mvn 
clean install at the root opennlp folder?
   - [x] Have you written or updated unit tests to verify your changes?
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)? 
   - [ ] If applicable, have you updated the LICENSE file, including the main 
LICENSE file in opennlp folder?
   - [ ] If applicable, have you updated the NOTICE file, including the main 
NOTICE file found in opennlp folder?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which 
it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions for 
build issues and submit an update to your PR as soon as possible.
   




> Clear open TODO in GenericFactoryTest
> -
>
> Key: OPENNLP-1590
> URL: https://issues.apache.org/jira/browse/OPENNLP-1590
> Project: OpenNLP
>  Issue Type: Test
>Affects Versions: 2.3.3
>Reporter: Martin Wiesner
>Assignee: Martin Wiesner
>Priority: Minor
> Fix For: 2.4.0
>
>
> The test case _testDictionaryArtifactToSerializerMappingExtraction()_ in 
> _GeneratorFactoryTest_ has a TODO note that can be cleared by adjusting the 
> test case slightly, as well as the related inconsistent implementation 
> class(es).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (OPENNLP-1590) Clear open TODO in GenericFactoryTest

2024-07-06 Thread Martin Wiesner (Jira)
Martin Wiesner created OPENNLP-1590:
---

 Summary: Clear open TODO in GenericFactoryTest
 Key: OPENNLP-1590
 URL: https://issues.apache.org/jira/browse/OPENNLP-1590
 Project: OpenNLP
  Issue Type: Test
Affects Versions: 2.3.3
Reporter: Martin Wiesner
Assignee: Martin Wiesner
 Fix For: 2.4.0


The test case _testDictionaryArtifactToSerializerMappingExtraction()_ in 
_GeneratorFactoryTest_ has a TODO note that can be cleared by adjusting the 
test case slightly, as well as the related inconsistent implementation 
class(es).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Assigned] (OPENNLP-1568) opennlp command fails when invoked from outside $OPENNLP_HOME/bin directory

2024-07-06 Thread Martin Wiesner (Jira)


 [ 
https://issues.apache.org/jira/browse/OPENNLP-1568?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Wiesner reassigned OPENNLP-1568:
---

Assignee: Bruno P. Kinoshita

> opennlp command fails when invoked from outside $OPENNLP_HOME/bin directory
> ---
>
> Key: OPENNLP-1568
> URL: https://issues.apache.org/jira/browse/OPENNLP-1568
> Project: OpenNLP
>  Issue Type: Bug
>  Components: Command Line Interface
>Affects Versions: 2.3.3
> Environment: Linux/Bash
>Reporter: Alexander Veit
>Assignee: Bruno P. Kinoshita
>Priority: Major
> Fix For: 2.4.0
>
>
> Try to run the opennlp command from outside $OPENNLP_HOME/bin directory.
> It fails with an error message similar to
>  
> {noformat}
> 2024-06-15T22:44:04.900344345Z main ERROR Reconfiguration failed:
>  No configuration found for '4f2410ac' at 'null' in 'null'{noformat}
>  
> The error is caused by the relative path in
> {code:java}
> -Dlog4j.configurationFile=../conf/log4j2.xml {code}
> of the opennlp script.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Closed] (OPENNLP-1589) Fix incorrect array check in CachedFeatureGenerator

2024-07-06 Thread Martin Wiesner (Jira)


 [ 
https://issues.apache.org/jira/browse/OPENNLP-1589?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Wiesner closed OPENNLP-1589.
---
Resolution: Invalid

The topic is different and a new issue which better describes the context is 
likely.

> Fix incorrect array check in CachedFeatureGenerator
> ---
>
> Key: OPENNLP-1589
> URL: https://issues.apache.org/jira/browse/OPENNLP-1589
> Project: OpenNLP
>  Issue Type: Bug
>  Components: Name Finder
>Affects Versions: 2.3.3
>Reporter: Martin Wiesner
>Assignee: Richard Zowalla
>Priority: Major
> Fix For: 2.4.0
>
>
> There is an invalid comparison for equality of two arrays in 
> CachedFeatureGenerator#createFeatures(..) in line 58.
> Currently, many situations exists in which no improvements by the caching are 
> achieved (as intended).
> This should be repaired and a test shall show the cache mechanism is working 
> correctly.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Closed] (OPENNLP-1588) Clean out deprecated code marked for removal

2024-07-06 Thread Martin Wiesner (Jira)


 [ 
https://issues.apache.org/jira/browse/OPENNLP-1588?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Wiesner closed OPENNLP-1588.
---
Resolution: Resolved

> Clean out deprecated code marked for removal 
> -
>
> Key: OPENNLP-1588
> URL: https://issues.apache.org/jira/browse/OPENNLP-1588
> Project: OpenNLP
>  Issue Type: Task
>Affects Versions: 2.3.0, 2.3.1, 2.3.2, 2.3.3
>Reporter: Martin Wiesner
>Assignee: Martin Wiesner
>Priority: Minor
> Fix For: 2.4.0
>
>
> Some record classes (still) carry convenience getters around, which are 
> marked for removal for more than 1y now. Some other deprecated code fragments 
> can also be removed now, since those are deprecated much longer and marked 
> for removal.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (OPENNLP-1588) Clean out deprecated code marked for removal

2024-07-06 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/OPENNLP-1588?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17863456#comment-17863456
 ] 

ASF GitHub Bot commented on OPENNLP-1588:
-

mawiesne merged PR #632:
URL: https://github.com/apache/opennlp/pull/632




> Clean out deprecated code marked for removal 
> -
>
> Key: OPENNLP-1588
> URL: https://issues.apache.org/jira/browse/OPENNLP-1588
> Project: OpenNLP
>  Issue Type: Task
>Affects Versions: 2.3.0, 2.3.1, 2.3.2, 2.3.3
>Reporter: Martin Wiesner
>Assignee: Martin Wiesner
>Priority: Minor
> Fix For: 2.4.0
>
>
> Some record classes (still) carry convenience getters around, which are 
> marked for removal for more than 1y now. Some other deprecated code fragments 
> can also be removed now, since those are deprecated much longer and marked 
> for removal.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)