sergey-tihon / Stanford.NLP.NET

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

dependency parser problem in asp.net app #43

Closed mehmetilker closed 8 years ago

mehmetilker commented 8 years ago

Everthing works fine with all annotators in console application but I got this exception when I try on asp.net mvc. If I remove depparse it works. So the problem is depparse on asp.net or it is same for parse annotator too.

Is there any setting I need to change ?

image

The code is as follows:

`

var jarRoot = @"D:\Projects\nlp\stanford-corenlp-full-2015-12-09\stanford-corenlp-3.6.0-models";

        var text = "For the month of January, I've resolved to attempt to wean myself off sugar's toxic allure.";

        var props = new Properties();
        props.setProperty("annotators", "tokenize, ssplit, pos, lemma, depparse"); //not working : coref, mention
        //props.setProperty("annotators", "tokenize, ssplit, pos, depparse, lemma, ner, parse, dcoref"); //not working : coref, mention
        props.setProperty("ner.useSUTime", "0");

        // We should change current directory, so StanfordCoreNLP could find all the model files automatically
        var curDir = Environment.CurrentDirectory;
        Directory.SetCurrentDirectory(jarRoot);
        var pipeline = new StanfordCoreNLP(props);
        Directory.SetCurrentDirectory(curDir);

        System.Console.WriteLine("Setting configuration complated");

        // Annotation
        var document = new Annotation(text);
        pipeline.annotate(document);`
sergey-tihon commented 8 years ago

Option 1 Try IIS (not IIS express) - https://github.com/sergey-tihon/Stanford.NLP.NET/issues/15#issuecomment-77526331

Option 2 Try to increase stack size - https://github.com/sergey-tihon/Stanford.NLP.NET/issues/16#issuecomment-164655567

mehmetilker commented 8 years ago

Thank you for your quick reply. I could not try on my local but it worked on Azure. So it is a problem related with IIS Express I assume.

mehmetilker commented 8 years ago

I would like to add some observations..

As I see leaving IIS express is some cumbersome just for this problem I tried to increase stack size with utilizing Thread class but unfortunately it is not possible to handle return value in asp.net project. Not directly related but close to it; other option is Task.Run but there is no way to set maxStackSize...

There should be setting for IIS Express.

new System.Threading.Thread(() =>
            {

            ......

                pipeline.annotate(document);
           ......
            }, 414565).Start();
mehmetilker commented 8 years ago

For those who is wondering a simple solution:

By default II express is working in 32 bit mode. And according to this article https://support.microsoft.com/en-us/kb/932909 " In Windows Server 2008 and higher, the maximum stack size of a thread running on 32-bit version of IIS is 256 KB, and on an x64 server is 512 KB." All we need is little bit higher then 400K for depparse annotator.

So we can set 64bit version of IIS Express in VS 2015 Tools> Options> Projects and Solutions > Web Projects > Use the 64 bit version of IIS Express for web sites and projects

happy codings...

sergey-tihon commented 8 years ago

Thank you @mehmetilker !

mehmetilker commented 8 years ago

You are welcome @sergey-tihon. Thank you for your effort.