yakivyusin / SimpleNetNlp

.NET NLP library
MIT License
48 stars 9 forks source link

Errors when trying to run SimpleNetNlp in F# interactive #1

Closed Shredderroy closed 6 years ago

Shredderroy commented 7 years ago

I have the following code in my F# interactive:

#I @"C:\Users\amit-\Documents\Visual Studio 2017\Projects\NLPTest\NLPTest\nlp-libs"
#I @"C:\Users\amit-\Documents\Visual Studio 2017\Projects\NLPTest\NLPTest\nlp-models\pos"
#I @"C:\Users\amit-\Documents\Visual Studio 2017\Projects\NLPTest\NLPTest\nlp-models\sentiment"
#I @"C:\Users\amit-\Documents\Visual Studio 2017\Projects\NLPTest\NLPTest\nlp-models\parser"
#I @"C:\Users\amit-\Documents\Visual Studio 2017\Projects\NLPTest\NLPTest\nlp-models\naturalli"
#I @"C:\Users\amit-\Documents\Visual Studio 2017\Projects\NLPTest\NLPTest\nlp-models\ner"
#I @"C:\Users\amit-\Documents\Visual Studio 2017\Projects\NLPTest\NLPTest\nlp-models\lexparser"

#r @"C:\Users\amit-\Documents\Visual Studio 2017\Projects\NLPTest\packages\SimpleNetNlp.3.7.0.1\lib\SimpleNetNlp.dll"

open SimpleNetNlp

let sentence = Sentence "This is a sample sentence."
sentence.Lemmas |> Seq.iter (printfn "%s")

But when I try to run the code, I get the following error:

SimpleNetNlp.Exceptions.MissingModelException: Missing Pos Tagger Model (please install SimpleNetNlp.Models.PosTagger) ---> java.lang.RuntimeException: edu.stanford.nlp.io.RuntimeIOException: Error while loading a tagger model (probably missing model file) ---> edu.stanford.nlp.io.RuntimeIOException: Error while loading a tagger model (probably missing model file) ---> java.io.IOException: Unable to open "edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger" as class path, filename or URL

Could you please provide a more descriptive example of usage in your README file?

yakivyusin commented 7 years ago

Hi, Shredderroy!

Thank you for your report :)

Models packages use additional MSBuild .targets files to copy models to your target dir, where Stanford CoreNLP search them (it is single responsibility of these packages, they don't contains any assemblies etc). I don't have too much experience with F# and fsi.exe, but as I understood it doesn't run these .targets files.

In this case, you must manually copy models files into specified subdirectories in your target dir.

For SimpleNetNlp.Models.PosTagger: copy content of 'nlp-models\pos' directory to 'edu\stanford\nlp\models\pos-tagger\english-left3words\' in your target dir. For SimpleNetNlp.Models.Ner: copy content of 'nlp-models\ner' directory to 'edu\stanford\nlp\models\ner' in your target dir. For SimpleNetNlp.Models.Parser: copy content of 'nlp-models\parser' directory to 'edu\stanford\nlp\models\parser\nndep' in your target dir. For SimpleNetNlp.Models.LexParser: copy content of 'nlp-models\lexparser' directory to 'edu\stanford\nlp\models\lexparser' in your target dir. For SimpleNetNlp.Models.Naturalli: copy content of 'nlp-models\naturalli' directory to 'edu\stanford\nlp\models\naturalli' in your target dir. For SimpleNetNlp.Models.Sentiment: copy content of 'nlp-models\sentiment' directory to 'edu\stanford\nlp\models\sentiment' in your target dir.

I will include this info to readme too.

Shredderroy commented 7 years ago

Thanks a lot for that information. I think it explains why the error occurs in F# interactive, but not in the compiled exe file.

I will try to come up with a repeatable way to avoid these errors in F# interactive and post it here. I am sure there are others who might find the information useful.