title: How to suppress unmatched words in Stanford NER classifiers?
body: <p>I am new to Stanford NLP and NER and trying to train a custom classifier with a data sets of currencies and countries.</p>
  
  <p>My training data in training-data-currency.tsv looks like -</p>
  
  <pre><code>USD CURRENCY
  GBP CURRENCY
  </code></pre>
  
  <p>And, training data in training-data-countries.tsv looks like -</p>
  
  <pre><code>USA COUNTRY
  UK  COUNTRY
  </code></pre>
  
  <p>And, classifiers properties look like -</p>
  
  <pre><code>trainFileList = classifiers/training-data-currency.tsv,classifiers/training-data-countries.tsv
  ner.model=classifiers/english.conll.4class.distsim.crf.ser.gz,classifiers/english.muc.7class.distsim.crf.ser.gz,classifiers/english.all.3class.distsim.crf.ser.gz
  serializeTo = classifiers/my-classification-model.ser.gz
  map = word=0,answer=1
  
  useClassFeature=true
  useWord=true
  useNGrams=true
  #no ngrams will be included that do not contain either the
  #beginning or end of the word
  noMidNGrams=true
  useDisjunctive=true
  maxNGramLeng=6
  usePrev=true
  useNext=true
  useSequences=true
  usePrevSequences=true
  maxLeft=1
  #the next 4 deal with word shape features
  useTypeSeqs=true
  useTypeSeqs2=true
  useTypeySequences=true
  wordShape=chris2useLC
  </code></pre>
  
  <p>Java code to find the categories is -</p>
  
  <pre><code>LinkedHashMap&lt;String, LinkedHashSet&lt;String&gt;&gt; map = new&lt;String, LinkedHashSet&lt;String&gt;&gt; LinkedHashMap();
  NERClassifierCombiner classifier = null;
  try {
      classifier = new NERClassifierCombiner(true, true, 
              "C:\\Users\\perso\\Downloads\\stanford-ner-2015-04-20\\stanford-ner-2015-04-20\\classifiers\\my-classification-model.ser.gz"
              );
  } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  List&lt;List&lt;CoreLabel&gt;&gt; classify = classifier.classify("Zambia");
  for (List&lt;CoreLabel&gt; coreLabels : classify) {
      for (CoreLabel coreLabel : coreLabels) {
  
          String word = coreLabel.word();
          String category = coreLabel
                  .get(CoreAnnotations.AnswerAnnotation.class);
          if (!"O".equals(category)) {
              if (map.containsKey(category)) {
                  map.get(category).add(word);
              } else {
                  LinkedHashSet&lt;String&gt; temp = new LinkedHashSet&lt;String&gt;();
                  temp.add(word);
                  map.put(category, temp);
              }
              System.out.println(word + ":" + category);
          }
  
      }
  
  }
  </code></pre>
  
  <p>When I run the above code with input as "USD" or "UK", I get expected result as "CURRENCY" or "COUNTRY". But, when I input something like "Russia", return value is "CURRENCY" which is from the first train file in the properties. I am expecting 'O' would be returned for these values which is not present in my training dat.</p>
  
  <p>How can I achieve this behavior? Any pointers where I am going wrong would be really helpful.</p>