sergey-tihon / Stanford.NLP.NET

Stanford NLP for .NET
http://sergey-tihon.github.io/Stanford.NLP.NET/
MIT License
598 stars 123 forks source link

c# Load Model #61

Closed aliNader closed 7 years ago

aliNader commented 7 years ago

I have installed stanford-postagger-3.7.0 and the models and put it within the project, then write the below code

            // Loading POS Tagger
            var tagger = new MaxentTagger(@"models\arabic-train.tagger"); // This line throw the exception

            // Text for tagging
            var text = "خطأ أثناء تحميل الموديل";

            var sentences = MaxentTagger.tokenizeText(new java.io.StringReader(text)).toArray();
            foreach (List sentence in sentences)
            {
                var taggedSentence = tagger.tagSentence(sentence);
                Console.WriteLine(taggedSentence);
            }

but when i execute it, IO Exception is thrown said "Unable to open "models\arabic-train.tagger" as class path, filename or URL" please help.

sergey-tihon commented 7 years ago

Check that current directory+models\arabic-train.tagger is exist on your drive

aliNader commented 7 years ago

@sergey-tihon it is Exist in the project directory capture

sergey-tihon commented 7 years ago

but it does not mean that you copy files to target directory and does not mean that in the runtime you Environment.CurrentDirectory is equal to build target directory.

Please, put breakpoint on the like var tagger = new MaxentTagger(@"models\arabic-train.tagger"); and debug your current directory.

sergey-tihon commented 7 years ago

I hope that this is resolved already, if not - please read this http://sergey-tihon.github.io/Stanford.NLP.NET//faq.html#Stanford-NLP-CoreNLP-not-loading-models

aliNader commented 7 years ago

it is resolved, thanks :)

2017-05-02 7:00 GMT+03:00 Sergey Tihon notifications@github.com:

I hope that this is resolved already, if not - please read this http://sergey-tihon.github.io/Stanford.NLP.NET//faq.html# Stanford-NLP-CoreNLP-not-loading-models

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sergey-tihon/Stanford.NLP.NET/issues/61#issuecomment-298492000, or mute the thread https://github.com/notifications/unsubscribe-auth/AZJ-NCLl60zO0ywpuALevMdQFO-uw_5pks5r1qpFgaJpZM4MbATE .