gateplugin-LearningFramework icon indicating copy to clipboard operation
gateplugin-LearningFramework copied to clipboard

Implement our own options parsing class and use in Parms

Open johann-petrak opened this issue 8 years ago • 4 comments

Currently we use a modified version of apache commons-cli: originally it looked like the best match, then we had to hack it and now it turns out this was a very bad idea: GCP also uses commons-cli which gets loaded first so our code throws an exception:

java.lang.IllegalAccessError: tried to access method
org.apache.commons.cli.Options.getOptionGroups()Ljava/util/Collection;
from class org.apache.commons.cli.DefaultParser
        at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:113)
        at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:80)
        at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:64)
        at gate.plugin.learningframework.engines.Parms.<init>(Parms.java:93)
        at gate.plugin.learningframework.engines.EngineLibSVM.trainModel(EngineLibSVM.java:157)
        at gate.plugin.learningframework.LF_TrainClassification.afterLastDocument(LF_TrainClassification.java:201)
        at gate.plugin.learningframework.AbstractDocumentProcessor.controllerExecutionFinished(AbstractDocumentProcessor.java:100)
        at gate.creole.ConditionalSerialAnalyserController.invokeControllerExecutionFinished(ConditionalSerialAnalyserController.java:554)
        at gate.cloud.batch.PooledDocumentProcessor.dispose(PooledDocumentProcessor.java:367)
        at gate.cloud.batch.BatchRunner$JobMonitor.run(BatchRunner.java:364)
        at java.lang.Thread.run(Thread.java:745)

johann-petrak avatar Nov 24 '16 13:11 johann-petrak

Or move your hacked version into a different package.

ianroberts avatar Nov 24 '16 13:11 ianroberts

my question would be why do you need to hack it? surely there must be a way of using it "as is"

greenwoodma avatar Nov 24 '16 13:11 greenwoodma

Yes, changing the package name is probably a good idea until a proper fix is found. The change is small anyway, currently I just include the diff in the LF distribution

https://github.com/GateNLP/gateplugin-LearningFramework/blob/master/commons-cli.diff

Mark, I needed something to work differently in an urgency and hacking the right version was the fastest way to do this - I had always been planning on replacing it anyway (for other reasons as well) so I did not bother to make an attempt to do it right.

There is even an issue for part of what I need, but my impression is that commons-cli did not receive much love recently: https://issues.apache.org/jira/browse/CLI-257

johann-petrak avatar Nov 24 '16 14:11 johann-petrak

Accidently added wrong commit message

johann-petrak avatar Dec 14 '18 15:12 johann-petrak