stanfordnlp / CoreNLP

CoreNLP: A Java suite of core NLP tools for tokenization, sentence segmentation, NER, parsing, coreference, sentiment analysis, etc.
http://stanfordnlp.github.io/CoreNLP/
GNU General Public License v3.0
9.72k stars 2.7k forks source link

Adding custom annotators to CoreNLP Server #483

Closed natewatson999 closed 7 years ago

natewatson999 commented 7 years ago

I know that custom annotators can be added to CoreNLP, but I can't find a way to enable custom annotators within CoreNLP server. I need to be able to add features such as ClausIE to CoreNLP, and have them available in the same manner OpenIE or NER is usable via a network interface, but I haven't been able to find how. Is it possible to add custom annotators to CoreNLP Server?

loretoparisi commented 7 years ago

@natewatson999 to add custom annotators, see the proposed solution for the ner french annotator that it is missing in the CoreNLP distribution: https://github.com/stanfordnlp/CoreNLP/issues/475

J38 commented 7 years ago

You need to launch the server with a properties file: -serverProperties custom-annotators.properties

Here is an example of launching the server with a properties file:

// Run a server using Chinese properties java -Xmx4g edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-chinese.properties -port 9000 -timeout 15000

Your properties file should look like this:

customAnnotatorClass.custom.lemma = edu.stanford.nlp.examples.CustomLemmaAnnotator

annotators = tokenize,ssplit,pos,custom.lemma

custom.lemma.lemmaFile = custom-lemmas.txt

Don't include a list of annotators in your request, the list of annotators should be specified in the .properties file.

Also, you must make sure the new custom class is on the CLASSPATH when you run the server.

More extensive documentation:

https://stanfordnlp.github.io/CoreNLP/corenlp-server.html https://stanfordnlp.github.io/CoreNLP/new_annotator.html