komalsahedani / cleartk

Automatically exported from code.google.com/p/cleartk
0 stars 0 forks source link

EventTenseAnnotator model jar cannot be found #381

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Add EventTenseAnnotator in a pipeline:
aggregateBuilder.add(EventTenseAnnotator.FACTORY.getAnnotatorDescription());

What is the expected output?
Annotated Event Tense

What do you see instead?
Exception in thread "main" java.util.MissingResourceException: No classifier 
jar found at "eventtenseannotator\model.jar" for class 
org.cleartk.timeml.event.EventTenseAnnotator

What version of the product are you using? On what operating system?
cleartk-timeml 1.1.0. Windows 7 Professional. 

Original issue reported on code.google.com by chen.lin...@gmail.com on 2 Aug 2013 at 5:20

GoogleCodeExporter commented 9 years ago
The problem is likely this line in CleartkInternalModelFactory:

    String resourceName = JarClassifierBuilder.getModelJarFile(getAnnotatorClass().getSimpleName().toLowerCase()).getPath(); 

It's using .getPath() and then using the result as part of a URI, but 
.getPath() on Windows returns '\' characters. That code should instead do 
something like:

    String dirName = getAnnotatorClass().getSimpleName().toLowerCase();
    File resourceFile = JarClassifierBuilder.getModelJarFile(dirName);
    String resourceName = resourceFile.getPath().replaceAll("\\", "/");

(That last line is a hack, but there isn't a good way to go between a File and 
the path portion of a URI.)

The problem is, I don't have a Windows machine, so I don't know how to test 
this. In theory, EventAnnotatorsTest should already be failing on Windows. So 
if someone can:

(1) run EventAnnotatorsTest on Windows
(2) confirm that it fails
(3) make the change suggested above
(4) confirm that EventAnnotatorsTest passes

Then I can commit the above change and everything should be fixed.

Original comment by steven.b...@gmail.com on 2 Aug 2013 at 5:48

GoogleCodeExporter commented 9 years ago
Thank you. I tried the suggested fix, but get a different error about the last 
line:
String resourceName = resourceFile.getPath().replaceAll("\\", "/");

Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected 
internal error near index 1
\
 ^
    at java.util.regex.Pattern.error(Pattern.java:1713)
    at java.util.regex.Pattern.compile(Pattern.java:1466)
    at java.util.regex.Pattern.<init>(Pattern.java:1133)
    at java.util.regex.Pattern.compile(Pattern.java:823)
    at java.lang.String.replaceAll(String.java:2189)
    at org.cleartk.timeml.util.CleartkInternalModelFactory.getClassifierJarURL(CleartkInternalModelFactory.java:66)
    at org.cleartk.timeml.util.CleartkInternalModelFactory.getAnnotatorDescription(CleartkInternalModelFactory.java:113)
    at org.apache.ctakes.temporal.eval.EvaluationOfClearTKEventProperties.test(EvaluationOfClearTKEventProperties.java:135)
    at org.apache.ctakes.temporal.eval.EvaluationOfClearTKEventProperties.test(EvaluationOfClearTKEventProperties.java:1)
    at org.cleartk.eval.Evaluation_ImplBase.trainAndTest(Evaluation_ImplBase.java:77)
    at org.apache.ctakes.temporal.eval.EvaluationOfClearTKEventProperties.main(EvaluationOfClearTKEventProperties.java:92)

Original comment by chen.lin...@gmail.com on 5 Aug 2013 at 6:26

GoogleCodeExporter commented 9 years ago
I guess what you mean is:
String resourceName = resourceFile.getPath().replaceAll("\\\\", "/");

Original comment by chen.lin...@gmail.com on 5 Aug 2013 at 6:54

GoogleCodeExporter commented 9 years ago
Yeah, looks like it needs 4 backslashes. Did that work when you tried it?

Original comment by steven.b...@gmail.com on 6 Aug 2013 at 5:14

GoogleCodeExporter commented 9 years ago
Yes. 

Original comment by chen.lin...@gmail.com on 6 Aug 2013 at 8:13

GoogleCodeExporter commented 9 years ago
This issue was closed by revision dc78d0f33cf1.

Original comment by steven.b...@gmail.com on 25 Oct 2013 at 8:58

GoogleCodeExporter commented 9 years ago
I've applied the patch as discussed. If you find that this does not resolve the 
issue, please reopen the ticket.

Original comment by steven.b...@gmail.com on 25 Oct 2013 at 8:59