Package org.apache.stanbol.enhancer.engines.keywordextraction.impl.Suggestion

Examples of org.apache.stanbol.enhancer.engines.keywordextraction.impl.Suggestion.MATCH


            }
            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() ||
                    //NOTE (rwesten, 2012-05-21): Do not check if all covered
                    //  Tokens are found, but if all Tokens of the Label are
                    //  matched! (STANBOL-622)
                    //foundTokens == coveredTokens) &&
                    foundTokens >= labelTokens.length) &&
                    labelMatchScore >= 0.6f){
                //same as above
                //if(foundTokens == coveredTokens){
                if(foundTokens == labelTokens.length && 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
View Full Code Here

TOP

Related Classes of org.apache.stanbol.enhancer.engines.keywordextraction.impl.Suggestion.MATCH

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.