+ int matches = 0;
+ int index = 0;
+ double score = 0;
+ while (index < expression.length()) {
+ int position = expression.toLowerCase().indexOf(phraseString, index);
+ if (position == -1) {
+ break;
+ }
+ score += Math.pow(1 - position / (double) expression.length(), 2);
+ index = position + phraseString.length();
+ logger.log(Level.FINEST, "Got hit at position %d.", position);
+ ++matches;
+ }
+ logger.log(Level.FINEST, "Score: %f", score);
+ if (matches == 0) {