Exemplo n.º 1
0
 private int computePenalty(int pos, int length) throws IOException {
   if (length > SEARCH_MODE_KANJI_LENGTH) {
     boolean allKanji = true;
     // check if node consists of only kanji
     final int endPos = pos + length;
     for (int pos2 = pos; pos2 < endPos; pos2++) {
       if (!characterDefinition.isKanji((char) buffer.get(pos2))) {
         allKanji = false;
         break;
       }
     }
     if (allKanji) { // Process only Kanji keywords
       return (length - SEARCH_MODE_KANJI_LENGTH) * SEARCH_MODE_KANJI_PENALTY;
     } else if (length > SEARCH_MODE_OTHER_LENGTH) {
       return (length - SEARCH_MODE_OTHER_LENGTH) * SEARCH_MODE_OTHER_PENALTY;
     }
   }
   return 0;
 }