@Override
  public void addCandidates(LemmaInstance instance, LemmaCandidateSet set) {
    ToutanovaInstance tinstance = getToutanovaInstance(instance);

    if (nbest_decoder_ == null) {
      nbest_decoder_ = new ZeroOrderNbestDecoder(options_.getNbestRank());
      nbest_decoder_.init(model_);
    }

    Collection<lemming.lemma.toutanova.Result> results = nbest_decoder_.decode(tinstance);
    if (results == null) return;

    for (lemming.lemma.toutanova.Result result : results) {
      set.getCandidate(result.getOutput());
    }
  }
  @Override
  public String lemmatize(LemmaInstance instance) {
    if (cache_ == null) {
      cache_ = new HashMap<>();
    }

    String lemma = cache_.get(instance);
    if (lemma != null) return lemma;

    if (decoder_ == null) {
      decoder_ = options_.getDecoderInstance();
      decoder_.init(model_);
    }

    ToutanovaInstance tinstance = getToutanovaInstance(instance);
    lemma = decoder_.decode(tinstance).getOutput();

    if (lemma == null || lemma.isEmpty()) {
      lemma = "_";
    }

    cache_.put(instance, lemma);
    return lemma;
  }