Reinitializing Stanford CoreNLP pipeline to match RegexNER file changesResolve coreference using Stanford CoreNLP - unable to load parser modelConcurrent processing using Stanford CoreNLP (3.5.2)Stanford NLP: java.lang.IllegalArgumentException: No annotator named openieStanford CoreNLP dedicated server ignoring annotators inputprogram for tagger and sentiment analysis in stanford nlpDynamically add properties to StanfordCoreNLP Annotator or Pipelineproblems with using regexner to override existing named entities while maintaining entitymentionsStandord-corenlp regexner and tokenregex not working for chineseStanford CoreNLP - lemmas are not recognised correctlyStanford RegexNER Example: Cannot find or load main class

Clarification on defining FFT bin sizes

When to ask for constructive criticism?

Is the Warlock's Hexblade Curse unaffected by an Antimagic Field?

Using two linked programs, output ordinal numbers up to n

Manually select/unselect lines before forwarding to stdout

Can't update Ubuntu 18.04.2

Video editor for YouTube

Can a Resident Assistant Be Told to Ignore a Lawful Order?

What do mathematicians mean when they say some conjecture can’t be proven using the current technology?

Why doesn't philosophy have higher standards for its arguments?

I won USD 50K! Now what should I do with it?

What is the technical explanation of the note "A♭" in a F7 chord in the key of C?

Was Willow's first magic display (blazing arrow through arm) actual magic, and if not, what's the trick?

What impact would a dragon the size of Asia have on the environment?

Why hasn't the U.S. government paid war reparations to any country it attacked?

Why use null function instead of == [] to check for empty list in Haskell?

Why is "dark" an adverb in this sentence?

Did 007 exist before James Bond?

Why does the Earth have a z-component at the start of the J2000 epoch?

Is there a way to handmake alphabet pasta?

If a player tries to persuade somebody, what should that creature roll not to be persuaded?

Can you perfectly wrap a cube with this blocky shape?

Why isn't aluminium involved in biological processes?

What exactly is a Hadouken?



Reinitializing Stanford CoreNLP pipeline to match RegexNER file changes


Resolve coreference using Stanford CoreNLP - unable to load parser modelConcurrent processing using Stanford CoreNLP (3.5.2)Stanford NLP: java.lang.IllegalArgumentException: No annotator named openieStanford CoreNLP dedicated server ignoring annotators inputprogram for tagger and sentiment analysis in stanford nlpDynamically add properties to StanfordCoreNLP Annotator or Pipelineproblems with using regexner to override existing named entities while maintaining entitymentionsStandord-corenlp regexner and tokenregex not working for chineseStanford CoreNLP - lemmas are not recognised correctlyStanford RegexNER Example: Cannot find or load main class






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am developing an application where I am sending new rules to the RegexNER file via a REST HTTP PATCH endpoint.



[Route("RegexNER")]
[HttpPatch]
public IHttpActionResult UpdateRegexNERFile([FromBody] List<RegexNERUpdateDTO> UpdateEntries)

if (UpdateEntries == null)
return Content(HttpStatusCode.BadRequest, new message = "Cannot update Regex NER for invalid requests!" );

string regexNERFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~"), "Models", "regexner_custom.txt");
string regexFileContents = File.ReadAllText(regexNERFilePath);

List<string> newEntryList = new List<string>();

foreach (RegexNERUpdateDTO entry in UpdateEntries)

foreach (string entityEntry in entry.Entries)

string newEntry = $"entityEntrytentry.Entity";

if (regexFileContents.IndexOf(newEntry, StringComparison.OrdinalIgnoreCase) == -1)
newEntryList.Add(newEntry);



// Remove read only file access
FileInfo myFile = new FileInfo(regexNERFilePath)

IsReadOnly = false
;

File.AppendAllText(regexNERFilePath, Environment.NewLine + string.Join(Environment.NewLine, newEntryList));
NLPInitializer.InitializeCoreNLP();
return Ok();



This is the code for initializing the CoreNLP pipeline:



public static class NLPInitializer

public static StanfordCoreNLP Pipeline get; set;

/// <summary>
/// This method is called only once (at startup) to initialize the StanfordCoreNLP pipeline object
/// </summary>
public static void InitializeCoreNLP()

// Path to the folder with models extracted from `stanford-corenlp-3.8.0-models.jar`
string jarRoot = ConfigurationManager.AppSettings["CoreNLPModelPath"];
string modelsDirectory = Path.Combine(jarRoot, "edu", "stanford", "nlp", "models");

// SUTime configuration
string sutimeRules = Path.Combine(modelsDirectory, "sutime", "defs.sutime.txt") + "," +
// Path.Combine(modelsDirectory, "sutime", "english.holidays.sutime.txt") + "," +
Path.Combine(modelsDirectory, "sutime", "english.sutime.txt");
try

Properties props = new Properties();
//props.setProperty("ner.model", Path.Combine(modelsDirectory + "ner", "english.muc.7class.distsim.crf.ser.gz"));
string regexNerFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~"), "Models", "regexner_custom.txt");
props.setProperty("regexner.mapping", regexNerFilePath);
props.setProperty("regexner.ignorecase", "true");
props.setProperty("coref.algorithm", "neural");
//props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,depparse,mention,coref,sentiment,regexner,relation,natlog,openie");
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,depparse,coref,sentiment,regexner,relation,natlog,openie");
//props.setProperty("ner.useSUTime", "0");
props.setProperty("sutime.rules", sutimeRules);
props.setProperty("sutime.binders", "0");
props.setProperty("openie.resolve_coref", "false");

string curDir = Environment.CurrentDirectory;
Directory.SetCurrentDirectory(jarRoot);
Pipeline = new StanfordCoreNLP(props);
Pipeline.addAnnotator(new TimeAnnotator("sutime", props));
Directory.SetCurrentDirectory(curDir);

catch (Exception ex)

throw;





But the problem is in this line
NLPInitializer.InitializeCoreNLP();



I want to re-initialize the Stanford CoreNLP pipeline such that picks up the latest changes made to the RegexNER file and finds the entity based on the updated rules.



But its the pipeline is not re-initializing, I don't know why.



One thing to be noticed is when I restart IIS or restart the app from inetmgr then CoreNLP picks up the latest changes made to the RegexNER file.



But restarting the IIS server is not feasible for every HTTP PATCH request, is there any alternative to this problem.



I am using CoreNLP v3.9.1 english model and CoreNLP 3.9.1 C# Nuget.










share|improve this question






























    0















    I am developing an application where I am sending new rules to the RegexNER file via a REST HTTP PATCH endpoint.



    [Route("RegexNER")]
    [HttpPatch]
    public IHttpActionResult UpdateRegexNERFile([FromBody] List<RegexNERUpdateDTO> UpdateEntries)

    if (UpdateEntries == null)
    return Content(HttpStatusCode.BadRequest, new message = "Cannot update Regex NER for invalid requests!" );

    string regexNERFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~"), "Models", "regexner_custom.txt");
    string regexFileContents = File.ReadAllText(regexNERFilePath);

    List<string> newEntryList = new List<string>();

    foreach (RegexNERUpdateDTO entry in UpdateEntries)

    foreach (string entityEntry in entry.Entries)

    string newEntry = $"entityEntrytentry.Entity";

    if (regexFileContents.IndexOf(newEntry, StringComparison.OrdinalIgnoreCase) == -1)
    newEntryList.Add(newEntry);



    // Remove read only file access
    FileInfo myFile = new FileInfo(regexNERFilePath)

    IsReadOnly = false
    ;

    File.AppendAllText(regexNERFilePath, Environment.NewLine + string.Join(Environment.NewLine, newEntryList));
    NLPInitializer.InitializeCoreNLP();
    return Ok();



    This is the code for initializing the CoreNLP pipeline:



    public static class NLPInitializer

    public static StanfordCoreNLP Pipeline get; set;

    /// <summary>
    /// This method is called only once (at startup) to initialize the StanfordCoreNLP pipeline object
    /// </summary>
    public static void InitializeCoreNLP()

    // Path to the folder with models extracted from `stanford-corenlp-3.8.0-models.jar`
    string jarRoot = ConfigurationManager.AppSettings["CoreNLPModelPath"];
    string modelsDirectory = Path.Combine(jarRoot, "edu", "stanford", "nlp", "models");

    // SUTime configuration
    string sutimeRules = Path.Combine(modelsDirectory, "sutime", "defs.sutime.txt") + "," +
    // Path.Combine(modelsDirectory, "sutime", "english.holidays.sutime.txt") + "," +
    Path.Combine(modelsDirectory, "sutime", "english.sutime.txt");
    try

    Properties props = new Properties();
    //props.setProperty("ner.model", Path.Combine(modelsDirectory + "ner", "english.muc.7class.distsim.crf.ser.gz"));
    string regexNerFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~"), "Models", "regexner_custom.txt");
    props.setProperty("regexner.mapping", regexNerFilePath);
    props.setProperty("regexner.ignorecase", "true");
    props.setProperty("coref.algorithm", "neural");
    //props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,depparse,mention,coref,sentiment,regexner,relation,natlog,openie");
    props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,depparse,coref,sentiment,regexner,relation,natlog,openie");
    //props.setProperty("ner.useSUTime", "0");
    props.setProperty("sutime.rules", sutimeRules);
    props.setProperty("sutime.binders", "0");
    props.setProperty("openie.resolve_coref", "false");

    string curDir = Environment.CurrentDirectory;
    Directory.SetCurrentDirectory(jarRoot);
    Pipeline = new StanfordCoreNLP(props);
    Pipeline.addAnnotator(new TimeAnnotator("sutime", props));
    Directory.SetCurrentDirectory(curDir);

    catch (Exception ex)

    throw;





    But the problem is in this line
    NLPInitializer.InitializeCoreNLP();



    I want to re-initialize the Stanford CoreNLP pipeline such that picks up the latest changes made to the RegexNER file and finds the entity based on the updated rules.



    But its the pipeline is not re-initializing, I don't know why.



    One thing to be noticed is when I restart IIS or restart the app from inetmgr then CoreNLP picks up the latest changes made to the RegexNER file.



    But restarting the IIS server is not feasible for every HTTP PATCH request, is there any alternative to this problem.



    I am using CoreNLP v3.9.1 english model and CoreNLP 3.9.1 C# Nuget.










    share|improve this question


























      0












      0








      0








      I am developing an application where I am sending new rules to the RegexNER file via a REST HTTP PATCH endpoint.



      [Route("RegexNER")]
      [HttpPatch]
      public IHttpActionResult UpdateRegexNERFile([FromBody] List<RegexNERUpdateDTO> UpdateEntries)

      if (UpdateEntries == null)
      return Content(HttpStatusCode.BadRequest, new message = "Cannot update Regex NER for invalid requests!" );

      string regexNERFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~"), "Models", "regexner_custom.txt");
      string regexFileContents = File.ReadAllText(regexNERFilePath);

      List<string> newEntryList = new List<string>();

      foreach (RegexNERUpdateDTO entry in UpdateEntries)

      foreach (string entityEntry in entry.Entries)

      string newEntry = $"entityEntrytentry.Entity";

      if (regexFileContents.IndexOf(newEntry, StringComparison.OrdinalIgnoreCase) == -1)
      newEntryList.Add(newEntry);



      // Remove read only file access
      FileInfo myFile = new FileInfo(regexNERFilePath)

      IsReadOnly = false
      ;

      File.AppendAllText(regexNERFilePath, Environment.NewLine + string.Join(Environment.NewLine, newEntryList));
      NLPInitializer.InitializeCoreNLP();
      return Ok();



      This is the code for initializing the CoreNLP pipeline:



      public static class NLPInitializer

      public static StanfordCoreNLP Pipeline get; set;

      /// <summary>
      /// This method is called only once (at startup) to initialize the StanfordCoreNLP pipeline object
      /// </summary>
      public static void InitializeCoreNLP()

      // Path to the folder with models extracted from `stanford-corenlp-3.8.0-models.jar`
      string jarRoot = ConfigurationManager.AppSettings["CoreNLPModelPath"];
      string modelsDirectory = Path.Combine(jarRoot, "edu", "stanford", "nlp", "models");

      // SUTime configuration
      string sutimeRules = Path.Combine(modelsDirectory, "sutime", "defs.sutime.txt") + "," +
      // Path.Combine(modelsDirectory, "sutime", "english.holidays.sutime.txt") + "," +
      Path.Combine(modelsDirectory, "sutime", "english.sutime.txt");
      try

      Properties props = new Properties();
      //props.setProperty("ner.model", Path.Combine(modelsDirectory + "ner", "english.muc.7class.distsim.crf.ser.gz"));
      string regexNerFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~"), "Models", "regexner_custom.txt");
      props.setProperty("regexner.mapping", regexNerFilePath);
      props.setProperty("regexner.ignorecase", "true");
      props.setProperty("coref.algorithm", "neural");
      //props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,depparse,mention,coref,sentiment,regexner,relation,natlog,openie");
      props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,depparse,coref,sentiment,regexner,relation,natlog,openie");
      //props.setProperty("ner.useSUTime", "0");
      props.setProperty("sutime.rules", sutimeRules);
      props.setProperty("sutime.binders", "0");
      props.setProperty("openie.resolve_coref", "false");

      string curDir = Environment.CurrentDirectory;
      Directory.SetCurrentDirectory(jarRoot);
      Pipeline = new StanfordCoreNLP(props);
      Pipeline.addAnnotator(new TimeAnnotator("sutime", props));
      Directory.SetCurrentDirectory(curDir);

      catch (Exception ex)

      throw;





      But the problem is in this line
      NLPInitializer.InitializeCoreNLP();



      I want to re-initialize the Stanford CoreNLP pipeline such that picks up the latest changes made to the RegexNER file and finds the entity based on the updated rules.



      But its the pipeline is not re-initializing, I don't know why.



      One thing to be noticed is when I restart IIS or restart the app from inetmgr then CoreNLP picks up the latest changes made to the RegexNER file.



      But restarting the IIS server is not feasible for every HTTP PATCH request, is there any alternative to this problem.



      I am using CoreNLP v3.9.1 english model and CoreNLP 3.9.1 C# Nuget.










      share|improve this question
















      I am developing an application where I am sending new rules to the RegexNER file via a REST HTTP PATCH endpoint.



      [Route("RegexNER")]
      [HttpPatch]
      public IHttpActionResult UpdateRegexNERFile([FromBody] List<RegexNERUpdateDTO> UpdateEntries)

      if (UpdateEntries == null)
      return Content(HttpStatusCode.BadRequest, new message = "Cannot update Regex NER for invalid requests!" );

      string regexNERFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~"), "Models", "regexner_custom.txt");
      string regexFileContents = File.ReadAllText(regexNERFilePath);

      List<string> newEntryList = new List<string>();

      foreach (RegexNERUpdateDTO entry in UpdateEntries)

      foreach (string entityEntry in entry.Entries)

      string newEntry = $"entityEntrytentry.Entity";

      if (regexFileContents.IndexOf(newEntry, StringComparison.OrdinalIgnoreCase) == -1)
      newEntryList.Add(newEntry);



      // Remove read only file access
      FileInfo myFile = new FileInfo(regexNERFilePath)

      IsReadOnly = false
      ;

      File.AppendAllText(regexNERFilePath, Environment.NewLine + string.Join(Environment.NewLine, newEntryList));
      NLPInitializer.InitializeCoreNLP();
      return Ok();



      This is the code for initializing the CoreNLP pipeline:



      public static class NLPInitializer

      public static StanfordCoreNLP Pipeline get; set;

      /// <summary>
      /// This method is called only once (at startup) to initialize the StanfordCoreNLP pipeline object
      /// </summary>
      public static void InitializeCoreNLP()

      // Path to the folder with models extracted from `stanford-corenlp-3.8.0-models.jar`
      string jarRoot = ConfigurationManager.AppSettings["CoreNLPModelPath"];
      string modelsDirectory = Path.Combine(jarRoot, "edu", "stanford", "nlp", "models");

      // SUTime configuration
      string sutimeRules = Path.Combine(modelsDirectory, "sutime", "defs.sutime.txt") + "," +
      // Path.Combine(modelsDirectory, "sutime", "english.holidays.sutime.txt") + "," +
      Path.Combine(modelsDirectory, "sutime", "english.sutime.txt");
      try

      Properties props = new Properties();
      //props.setProperty("ner.model", Path.Combine(modelsDirectory + "ner", "english.muc.7class.distsim.crf.ser.gz"));
      string regexNerFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~"), "Models", "regexner_custom.txt");
      props.setProperty("regexner.mapping", regexNerFilePath);
      props.setProperty("regexner.ignorecase", "true");
      props.setProperty("coref.algorithm", "neural");
      //props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,depparse,mention,coref,sentiment,regexner,relation,natlog,openie");
      props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,depparse,coref,sentiment,regexner,relation,natlog,openie");
      //props.setProperty("ner.useSUTime", "0");
      props.setProperty("sutime.rules", sutimeRules);
      props.setProperty("sutime.binders", "0");
      props.setProperty("openie.resolve_coref", "false");

      string curDir = Environment.CurrentDirectory;
      Directory.SetCurrentDirectory(jarRoot);
      Pipeline = new StanfordCoreNLP(props);
      Pipeline.addAnnotator(new TimeAnnotator("sutime", props));
      Directory.SetCurrentDirectory(curDir);

      catch (Exception ex)

      throw;





      But the problem is in this line
      NLPInitializer.InitializeCoreNLP();



      I want to re-initialize the Stanford CoreNLP pipeline such that picks up the latest changes made to the RegexNER file and finds the entity based on the updated rules.



      But its the pipeline is not re-initializing, I don't know why.



      One thing to be noticed is when I restart IIS or restart the app from inetmgr then CoreNLP picks up the latest changes made to the RegexNER file.



      But restarting the IIS server is not feasible for every HTTP PATCH request, is there any alternative to this problem.



      I am using CoreNLP v3.9.1 english model and CoreNLP 3.9.1 C# Nuget.







      stanford-nlp






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 6:33







      Kunal Mukherjee

















      asked Mar 26 at 7:33









      Kunal MukherjeeKunal Mukherjee

      3,2943 gold badges12 silver badges31 bronze badges




      3,2943 gold badges12 silver badges31 bronze badges






















          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55351881%2freinitializing-stanford-corenlp-pipeline-to-match-regexner-file-changes%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55351881%2freinitializing-stanford-corenlp-pipeline-to-match-regexner-file-changes%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript