Пример #1
0
 public void getScore(String value3, Score score) {
   if (value3 == null || value3.trim().equals("")) return;
   String value2 = value3.toLowerCase();
   if (query.equals(value2)) {
     score.equalsMatches++;
     score.isMatch = true;
     return;
   }
   try {
     int occurrences = value2.length() - value2.replaceAll(query, "").length();
     if (occurrences > 0) {
       score.completeMatches += occurrences;
       score.isMatch = true;
     }
     if (terms.length > 1) {
       int termNo = 0;
       for (String term : terms) {
         int count = value2.length() - value2.replaceAll(term, "").length();
         if (count > 0) {
           score.terms[termNo++] += count;
           score.isMatch = true;
         }
       }
     }
   } catch (PatternSyntaxException pse) {
     // assume no match on pattern syntax error
   }
 }
Пример #2
0
 public Score createScore() {
   Score score = new Score();
   score.terms = new int[terms.length];
   return score;
 }