private static Stats computeOverDivide(ArrayList<Integer> ngram,References references,int boundary){
  HashMap<String,Integer> boundaryNgrams=new HashMap<>();
  for (int width=1; width <= Math.min(maxOrder,ngram.size()); width++) {
    for (int i=0; i < ngram.size() - width + 1; i++) {
      int j=i + width;
      final List<Integer> piece=ngram.subList(i,j);
      if (boundary == -1 || (boundary > i && boundary < j)) {
        String ngramStr=Vocabulary.getWords(piece);
        if (!boundaryNgrams.containsKey(ngramStr))         boundaryNgrams.put(ngramStr,1);
 else         boundaryNgrams.put(ngramStr,boundaryNgrams.get(ngramStr));
      }
    }
  }
  BLEU.Stats result=new BLEU.Stats();
  int[] stats=BLEU.computeNgramMatches(0,boundaryNgrams,references.ngramCounts,maxOrder);
  System.arraycopy(stats,1,result.counts,0,maxOrder);
  return result;
}

private static Stats computeOverDivide ( ArrayList < Integer > ngram , References references , int boundary ) { HashMap < String , Integer > boundaryNgrams = new HashMap < > ( ) ; for ( int width = 1 ; width <= Math . min ( maxOrder , ngram . size ( ) ) ; width ++ ) { for ( int i = 0 ; i < ngram . size ( ) - width + 1 ; i ++ ) { int j = i + width ; final List < Integer > piece = ngram . subList ( i , j ) ; if ( boundary == - 1 || ( boundary > i && boundary < j ) ) { String ngramStr = Vocabulary . getWords ( piece ) ; if ( ! boundaryNgrams . containsKey ( ngramStr ) ) boundaryNgrams . put ( ngramStr , 1 ) ; else boundaryNgrams . put ( ngramStr , boundaryNgrams . get ( ngramStr ) ) ; } } } BLEU . Stats result = new BLEU . Stats ( ) ; int [ ] stats = BLEU . computeNgramMatches ( 0 , boundaryNgrams , references . ngramCounts , maxOrder ) ; System . arraycopy ( stats , 1 , result . counts , 0 , maxOrder ) ; return result ; }
when computing bleu statistics over a rule , we need to avoid adding in ngrams that are exclusively contained inside tail nodes . this function accumulates all the eligible ngrams from a string respective of an optional boundary point , and then calls computengrammatches ( ) .
