@Override public float estimateCost(Rule rule){
  float lmEstimate=0.0f;
  boolean considerIncompleteNgrams=true;
  int[] enWords=getRuleIds(rule);
  List<Integer> words=new ArrayList<>();
  boolean skipStart=(enWords[0] == startSymbolId);
  for (  int currentWord : enWords) {
    if (FormatUtils.isNonterminal(currentWord)) {
      lmEstimate+=scoreChunkLogP(words,considerIncompleteNgrams,skipStart);
      words.clear();
      skipStart=false;
    }
 else {
      words.add(currentWord);
    }
  }
  lmEstimate+=scoreChunkLogP(words,considerIncompleteNgrams,skipStart);
  final float oovEstimate=(withOovFeature) ? getOovs(enWords) : 0f;
  return weight * lmEstimate + oovWeight * oovEstimate;
}

@ Override public float estimateCost ( Rule rule ) { float lmEstimate = 0.0f ; boolean considerIncompleteNgrams = true ; int [ ] enWords = getRuleIds ( rule ) ; List < Integer > words = new ArrayList < > ( ) ; boolean skipStart = ( enWords [ 0 ] == startSymbolId ) ; for ( int currentWord : enWords ) { if ( FormatUtils . isNonterminal ( currentWord ) ) { lmEstimate += scoreChunkLogP ( words , considerIncompleteNgrams , skipStart ) ; words . clear ( ) ; skipStart = false ; } else { words . add ( currentWord ) ; } } lmEstimate += scoreChunkLogP ( words , considerIncompleteNgrams , skipStart ) ; final float oovEstimate = ( withOovFeature ) ? getOovs ( enWords ) : 0f ; return weight * lmEstimate + oovWeight * oovEstimate ; }
this function computes all the complete n - grams found in the rule , as well as the incomplete n - grams on the left - hand side .
