}
labelIndex--;
}
//Now we make a second round to search tokens that match in the wrong order
//e.g. if given and family name of persons are switched
MATCH labelMatch;
int coveredTokens = lastFoundIndex-firstFoundIndex+1;
float labelMatchScore = (foundTokenMatch/(float)labelTokens.length);
//Matching rules
// - if less than config#minTokenFound() than accept only EXACT
// - override PARTIAL matches with FULL/EXACT matches only if
// foundTokens of the PARTIAL match is > than of the FULL/EXACT
// match (this will be very rare
if(foundProcessableTokens > 0 && match.getMatchCount() <= foundProcessableTokens) {
String currentText = state.getTokenText(firstFoundIndex,coveredTokens);
if(config.isCaseSensitiveMatching() ? currentText.equals(text) : currentText.equalsIgnoreCase(text)){
labelMatch = MATCH.EXACT;
//set found to covered: May be lower because only
//processable tokens are counted, but Exact also checks
//of non-processable!
foundTokens = coveredTokens;
} else if((foundProcessableTokens >= config.getMinFoundTokens() ||
foundTokens == coveredTokens) &&
labelMatchScore >= 0.6f){
if(foundTokens == coveredTokens){
labelMatch = MATCH.FULL;
} else {
labelMatch = MATCH.PARTIAL;
}
} else {
labelMatch = MATCH.NONE;
}
if(labelMatch != MATCH.NONE){
if(match.getMatchCount() < foundProcessableTokens ||
match.getMatchCount() == foundProcessableTokens &&
labelMatch.ordinal() > match.getMatch().ordinal()){
match.updateMatch(labelMatch, firstFoundIndex, coveredTokens, foundTokens,
foundTokenMatch/foundTokens,label,labelTokens.length);
} //else this match is not better as the existing one
} //else ignore labels with MATCH.NONE
} //else NO tokens found -> nothing to do