Re: OpenNLP - Model version 1.6.0 not supported by this (1.5.3) version of OpenNLP
On 13.01.2017, at 11:41, David Samuel Limwrote: > > After all that has said, I have a question: > > *Why is it that when the references to the OpenNLP 1.6.0 libraries are > removed, the program "reverts" back to OpenNLP 1.5.3, and how do I undo > this? (i.e. when I re-add the 1.6.0 libraries, the program starts using > 1.6.0 instead of 1.5.3)* > Once again, thanks to all who have answered so far for their insight and > advice. That is because you OpenNLP classes are in multiple JARs on your classpath. Depending on the order in which the JARs are mentioned on the classpath, the one or the other version of these classes is preferred. How to fix this? a) make sure that you don't use fat JARs (cf. other mail I wrote). b) consider using a tool that manages your dependencies such as Maven, Gradle, or Ivy. I'd personally recommend Maven. It's a bit of another learning curve though. Cheers, -- Richard
Re: OpenNLP - Model version 1.6.0 not supported by this (1.5.3) version of OpenNLP
On 13.01.2017, at 08:29, David Samuel Limwrote: > > *> Maybe OpenNLP classes are included in some non-OpenNLP JAR as well that > you use in your project?* > > Sorry, I'm personally not sure what you mean by this. Could you please > clarify? Sometimes people create so-called fat JARs. That is, the build a JAR which not only contains their code, but also the code of each and every library that they are using. I have hit that problem in the past when I was using a JAR from a tool which included a full copy of the Stanford Parser. It meant, when I added a more recent version of the Stanford Parser to my project, unpredictable things would happen. Cheers, -- Richard
Re: Check OpenNLP build version of trained model
We should consider printing out basic information about the model when it is loaded with the CLI tools. Jörn On Fri, Jan 13, 2017 at 11:42 AM, William Colenwrote: > Yes. The model is a zip file. Extract it and you can find a metadata file > with this information. > > 2017-01-13 3:34 GMT-02:00 David Samuel Lim : > > > Hello, > > > > May I know if, given a custom trained OpenNLP model, there are any ways > to > > determine the OpenNLP version used to train it? > > > > Regards, > > David Lim > > >
Re: OpenNLP - Model version 1.6.0 not supported by this (1.5.3) version of OpenNLP
Thank you William and Richard for your help and advice. I think I may have discovered something. My project also references Apache Tika - the *tika-app-1.13.jar *library. I'm not very well-versed in Tika, but it apparently has its own implementation of the OpenNLP files. How did I discover this? *(Please bear with this long anecdotal post, I want to describe how I came across this findings.)* Firstly, I was conducting experiments to try and resolve this issue. One of the measures I took was to create a new Eclipse project. This new project was almost an exact replica of my old project - word-for-word, with the same naming conventions and program structure. It also made use of the same libraries - including the OpenNLP 1.6.0 and Apache Tika libraries. The new program initially worked well. It could load the custom model successfully. I experimented on this new program and decided to remove the OpenNLP 1.6.0 library references, then re-add them. This time, the program no longer worked, instead showing the exact same error as my old program did. I got curious, so I decided to try something. I removed the libraries again and observed the code. I was puzzled to see that the import statements for the OpenNLP classes in use did not show any errors. Then, I tried removing the reference to *tika-app-1.13.jar*. To my surprise, the import statements for the various OpenNLP classes in use showed errors (i.e. red underlines). At that point, I realized that it was in part due to Tika. True enough, upon examining the *tika-app-1.13.jar* file, I saw folders containing OpenNLP packages and files. Given the evidence so far, I strongly suspect that the OpenNLP version that Tika is implementing is 1.5.3. I'll investigate and experiment more throughout this week and the next. *(Please do excuse me; I am rather new to OpenNLP and Tika)* After all that has said, I have a question: *Why is it that when the references to the OpenNLP 1.6.0 libraries are removed, the program "reverts" back to OpenNLP 1.5.3, and how do I undo this? (i.e. when I re-add the 1.6.0 libraries, the program starts using 1.6.0 instead of 1.5.3)* Once again, thanks to all who have answered so far for their insight and advice. Regards, David On Fri, Jan 13, 2017 at 3:32 PM, David Samuel Limwrote: > Oops, I meant *opennlp-tools-1.5.3.jar*. My bad. > > On Fri, Jan 13, 2017 at 3:29 PM, David Samuel Lim > wrote: > >> Hi Richard, >> >> Thanks for the reply. I've checked the classpath again and it only shows >> the referenced 1.6.0 libraries. >> >> Though, when I initially faced the issue, one strategy I tried was to >> reference the *opennlp-tools-1.5.0.jar* library. It didn't work, so I >> removed it. None of the methods I've tried so far have given me a solid >> answer, not even re-training the model using 1.6.0. >> >> *> Maybe OpenNLP classes are included in some non-OpenNLP JAR as well >> that you use in your project?* >> >> Sorry, I'm personally not sure what you mean by this. Could you please >> clarify? >> >> Regards, >> David >> >> On Fri, Jan 13, 2017 at 3:14 PM, Richard Eckart de Castilho < >> r...@apache.org> wrote: >> >>> On 13.01.2017, at 02:51, David Samuel Lim wrote: >>> > >>> > *To sum up: Unable to load custom trained OpenNLP Name Finder model in >>> code >>> > due to apparent OpenNLP version incompatibility. Model was trained in >>> > OpenNLP 1.6.0, which my project also uses. Other projects also using >>> 1.6.0 >>> > were able to load the model successfully.* >>> >>> Maybe you have OpenNLP twice on the classpath for some reason, once in >>> 1.5.3 >>> and once in 1.6.0. Maybe OpenNLP classes are included in some >>> non-OpenNLP JAR >>> as well that you use in your project? >>> >>> Cheers, >>> >>> -- Richard >>> >> >> >
Re: OpenNLP - Model version 1.6.0 not supported by this (1.5.3) version of OpenNLP
Are you using Maven? 2017-01-13 5:32 GMT-02:00 David Samuel Lim: > Oops, I meant *opennlp-tools-1.5.3.jar*. My bad. > > On Fri, Jan 13, 2017 at 3:29 PM, David Samuel Lim > wrote: > > > Hi Richard, > > > > Thanks for the reply. I've checked the classpath again and it only shows > > the referenced 1.6.0 libraries. > > > > Though, when I initially faced the issue, one strategy I tried was to > > reference the *opennlp-tools-1.5.0.jar* library. It didn't work, so I > > removed it. None of the methods I've tried so far have given me a solid > > answer, not even re-training the model using 1.6.0. > > > > *> Maybe OpenNLP classes are included in some non-OpenNLP JAR as well > that > > you use in your project?* > > > > Sorry, I'm personally not sure what you mean by this. Could you please > > clarify? > > > > Regards, > > David > > > > On Fri, Jan 13, 2017 at 3:14 PM, Richard Eckart de Castilho < > > r...@apache.org> wrote: > > > >> On 13.01.2017, at 02:51, David Samuel Lim > wrote: > >> > > >> > *To sum up: Unable to load custom trained OpenNLP Name Finder model in > >> code > >> > due to apparent OpenNLP version incompatibility. Model was trained in > >> > OpenNLP 1.6.0, which my project also uses. Other projects also using > >> 1.6.0 > >> > were able to load the model successfully.* > >> > >> Maybe you have OpenNLP twice on the classpath for some reason, once in > >> 1.5.3 > >> and once in 1.6.0. Maybe OpenNLP classes are included in some > non-OpenNLP > >> JAR > >> as well that you use in your project? > >> > >> Cheers, > >> > >> -- Richard > >> > > > > >