Kunal Mukherjee
Kunal Mukherjee

Reputation: 5853

Override named entity with RegexNER instead of CRF model

I am trying to detect named entities using Stanford CoreNLP in a task.

I have already given a rule as follows in my RegexNER mapping file as follows:

Train   VEHICLE_TYPE    2.0

But its identifying Train as CRIMINAL_CHARGE type of entity.

I have added this option ner.applyFineGrained and set it to true maybe that's why its overriding with CoreNLP's CRF model.

My question is how to add exceptions like this in RegexNER mapping file or is there some better approach.

Upvotes: 0

Views: 175

Answers (1)

StanfordNLPHelp
StanfordNLPHelp

Reputation: 8739

You should use these settings:

# run fine-grained NER with a custom rules file
java -Xmx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner -ner.fine.regexner.mapping custom.rules -file example.txt -outputFormat text

You need to make sure to set ner.fine.regexner.mapping to your custom rules file to use that instead of the default fine-grained rules which would label things such as CRIMINAL_CHARGE

Upvotes: 1

Related Questions