亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? metaphone.java

?? 一個很實用的東東
?? JAVA
字號:
/*
 * Copyright 2001-2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ 

package org.apache.commons.codec.language;

import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.StringEncoder;

/**
 * Encodes a string into a metaphone value. 
 * <p>
 * Initial Java implementation by <CITE>William B. Brogden. December, 1997</CITE>. 
 * Permission given by <CITE>wbrogden</CITE> for code to be used anywhere.
 * </p>
 * <p>
 * <CITE>Hanging on the Metaphone</CITE> by <CITE>Lawrence Philips</CITE> in <CITE>Computer Language of Dec. 1990, p
 * 39.</CITE>
 * </p>
 * 
 * @author Apache Software Foundation
 * @version $Id: Metaphone.java,v 1.20 2004/06/05 18:32:04 ggregory Exp $
 */
public class Metaphone implements StringEncoder {

    /**
     * Five values in the English language 
     */
    private String vowels = "AEIOU" ;

    /**
     * Variable used in Metaphone algorithm
     */
    private String frontv = "EIY"   ;

    /**
     * Variable used in Metaphone algorithm
     */
    private String varson = "CSPTG" ;

    /**
     * The max code length for metaphone is 4
     */
    private int maxCodeLen = 4 ;

    /**
     * Creates an instance of the Metaphone encoder
     */
    public Metaphone() {
        super();
    }

    /**
     * Find the metaphone value of a String. This is similar to the
     * soundex algorithm, but better at finding similar sounding words.
     * All input is converted to upper case.
     * Limitations: Input format is expected to be a single ASCII word
     * with only characters in the A - Z range, no punctuation or numbers.
     *
     * @param txt String to find the metaphone code for
     * @return A metaphone code corresponding to the String supplied
     */
    public String metaphone(String txt) {
        boolean hard = false ;
        if ((txt == null) || (txt.length() == 0)) {
            return "" ;
        }
        // single character is itself
        if (txt.length() == 1) {
            return txt.toUpperCase() ;
        }
      
        char[] inwd = txt.toUpperCase().toCharArray() ;
      
        StringBuffer local = new StringBuffer(40); // manipulate
        StringBuffer code = new StringBuffer(10) ; //   output
        // handle initial 2 characters exceptions
        switch(inwd[0]) {
        case 'K' : 
        case 'G' : 
        case 'P' : /* looking for KN, etc*/
            if (inwd[1] == 'N') {
                local.append(inwd, 1, inwd.length - 1);
            } else {
                local.append(inwd);
            }
            break;
        case 'A': /* looking for AE */
            if (inwd[1] == 'E') {
                local.append(inwd, 1, inwd.length - 1);
            } else {
                local.append(inwd);
            }
            break;
        case 'W' : /* looking for WR or WH */
            if (inwd[1] == 'R') {   // WR -> R
                local.append(inwd, 1, inwd.length - 1); 
                break ;
            }
            if (inwd[1] == 'H') {
                local.append(inwd, 1, inwd.length - 1);
                local.setCharAt(0, 'W'); // WH -> W
            } else {
                local.append(inwd);
            }
            break;
        case 'X' : /* initial X becomes S */
            inwd[0] = 'S';
            local.append(inwd);
            break ;
        default :
            local.append(inwd);
        } // now local has working string with initials fixed

        int wdsz = local.length();
        int n = 0 ;

        while ((code.length() < this.getMaxCodeLen()) && 
        	   (n < wdsz) ) { // max code size of 4 works well
            char symb = local.charAt(n) ;
            // remove duplicate letters except C
            if ((symb != 'C') && (isPreviousChar( local, n, symb )) ) {
                n++ ;
            } else { // not dup
                switch(symb) {
                case 'A' : case 'E' : case 'I' : case 'O' : case 'U' :
                    if (n == 0) { 
                        code.append(symb);
                    }
                    break ; // only use vowel if leading char
                case 'B' :
                    if ( isPreviousChar(local, n, 'M') && 
                         isLastChar(wdsz, n) ) { // B is silent if word ends in MB
						break;
                    }
                    code.append(symb);
                    break;
                case 'C' : // lots of C special cases
                    /* discard if SCI, SCE or SCY */
                    if ( isPreviousChar(local, n, 'S') && 
                         !isLastChar(wdsz, n) && 
                         (this.frontv.indexOf(local.charAt(n + 1)) >= 0) ) { 
                        break;
                    }
                    if (regionMatch(local, n, "CIA")) { // "CIA" -> X
                        code.append('X'); 
                        break;
                    }
                    if (!isLastChar(wdsz, n) && 
                        (this.frontv.indexOf(local.charAt(n + 1)) >= 0)) {
                        code.append('S');
                        break; // CI,CE,CY -> S
                    }
                    if (isPreviousChar(local, n, 'S') &&
						isNextChar(local, n, 'H') ) { // SCH->sk
                        code.append('K') ; 
                        break ;
                    }
                    if (isNextChar(local, n, 'H')) { // detect CH
                        if ((n == 0) && 
                        	(wdsz >= 3) && 
                            isVowel(local,2) ) { // CH consonant -> K consonant
                            code.append('K');
                        } else { 
                            code.append('X'); // CHvowel -> X
                        }
                    } else { 
                        code.append('K');
                    }
                    break ;
                case 'D' :
                    if (!isLastChar(wdsz, n + 1) && 
                        isNextChar(local, n, 'G') && 
                        (this.frontv.indexOf(local.charAt(n + 2)) >= 0)) { // DGE DGI DGY -> J 
                        code.append('J'); n += 2 ;
                    } else { 
                        code.append('T');
                    }
                    break ;
                case 'G' : // GH silent at end or before consonant
                    if (isLastChar(wdsz, n + 1) && 
                        isNextChar(local, n, 'H')) {
                        break;
                    }
                    if (!isLastChar(wdsz, n + 1) &&  
                        isNextChar(local,n,'H') && 
                        !isVowel(local,n+2)) {
                        break;
                    }
                    if ((n > 0) && 
                    	( regionMatch(local, n, "GN") ||
					      regionMatch(local, n, "GNED") ) ) {
                        break; // silent G
                    }
                    if (isPreviousChar(local, n, 'G')) {
                        hard = true ;
                    } else {
                        hard = false ;
                    }
                    if (!isLastChar(wdsz, n) && 
                        (this.frontv.indexOf(local.charAt(n + 1)) >= 0) && 
                        (!hard)) {
                        code.append('J');
                    } else {
                        code.append('K');
                    }
                    break ;
                case 'H':
                    if (isLastChar(wdsz, n)) {
                        break ; // terminal H
                    }
                    if ((n > 0) && 
                        (this.varson.indexOf(local.charAt(n - 1)) >= 0)) {
                        break;
                    }
                    if (isVowel(local,n+1)) {
                        code.append('H'); // Hvowel
                    }
                    break;
                case 'F': 
                case 'J' : 
                case 'L' :
                case 'M': 
                case 'N' : 
                case 'R' :
                    code.append(symb); 
                    break;
                case 'K' :
                    if (n > 0) { // not initial
                        if (!isPreviousChar(local, n, 'C')) {
                            code.append(symb);
                        }
                    } else {
                        code.append(symb); // initial K
                    }
                    break ;
                case 'P' :
                    if (isNextChar(local,n,'H')) {
                        // PH -> F
                        code.append('F');
                    } else {
                        code.append(symb);
                    }
                    break ;
                case 'Q' :
                    code.append('K');
                    break;
                case 'S' :
                    if (regionMatch(local,n,"SH") || 
					    regionMatch(local,n,"SIO") || 
					    regionMatch(local,n,"SIA")) {
                        code.append('X');
                    } else {
                        code.append('S');
                    }
                    break;
                case 'T' :
                    if (regionMatch(local,n,"TIA") || 
						regionMatch(local,n,"TIO")) {
                        code.append('X'); 
                        break;
                    }
                    if (regionMatch(local,n,"TCH")) {
						// Silent if in "TCH"
                        break;
                    }
                    // substitute numeral 0 for TH (resembles theta after all)
                    if (regionMatch(local,n,"TH")) {
                        code.append('0');
                    } else {
                        code.append('T');
                    }
                    break ;
                case 'V' :
                    code.append('F'); break ;
                case 'W' : case 'Y' : // silent if not followed by vowel
                    if (!isLastChar(wdsz,n) && 
                    	isVowel(local,n+1)) {
                        code.append(symb);
                    }
                    break ;
                case 'X' :
                    code.append('K'); code.append('S');
                    break ;
                case 'Z' :
                    code.append('S'); break ;
                } // end switch
                n++ ;
            } // end else from symb != 'C'
            if (code.length() > this.getMaxCodeLen()) { 
            	code.setLength(this.getMaxCodeLen()); 
            }
        }
        return code.toString();
    }

	private boolean isVowel(StringBuffer string, int index) {
		return (this.vowels.indexOf(string.charAt(index)) >= 0);
	}

	private boolean isPreviousChar(StringBuffer string, int index, char c) {
		boolean matches = false;
		if( index > 0 &&
		    index < string.length() ) {
			matches = string.charAt(index - 1) == c;
		}
		return matches;
	}

	private boolean isNextChar(StringBuffer string, int index, char c) {
		boolean matches = false;
		if( index >= 0 &&
		    index < string.length() - 1 ) {
			matches = string.charAt(index + 1) == c;
		}
		return matches;
	}

	private boolean regionMatch(StringBuffer string, int index, String test) {
		boolean matches = false;
		if( index >= 0 &&
		    (index + test.length() - 1) < string.length() ) {
			String substring = string.substring( index, index + test.length());
			matches = substring.equals( test );
		}
		return matches;
	}

	private boolean isLastChar(int wdsz, int n) {
		return n + 1 == wdsz;
	} 
    
    
    /**
     * Encodes an Object using the metaphone algorithm.  This method
     * is provided in order to satisfy the requirements of the
     * Encoder interface, and will throw an EncoderException if the
     * supplied object is not of type java.lang.String.
     *
     * @param pObject Object to encode
     * @return An object (or type java.lang.String) containing the 
     *         metaphone code which corresponds to the String supplied.
     * @throws EncoderException if the parameter supplied is not
     *                          of type java.lang.String
     */
    public Object encode(Object pObject) throws EncoderException {
        if (!(pObject instanceof java.lang.String)) {
            throw new EncoderException("Parameter supplied to Metaphone encode is not of type java.lang.String"); 
        }
        return metaphone((String) pObject);
    }

    /**
     * Encodes a String using the Metaphone algorithm. 
     *
     * @param pString String object to encode
     * @return The metaphone code corresponding to the String supplied
     */
    public String encode(String pString) {
        return metaphone(pString);   
    }

    /**
     * Tests is the metaphones of two strings are identical.
     *
     * @param str1 First of two strings to compare
     * @param str2 Second of two strings to compare
     * @return true if the metaphones of these strings are identical, 
     *         false otherwise.
     */
    public boolean isMetaphoneEqual(String str1, String str2) {
        return metaphone(str1).equals(metaphone(str2));
    }

    /**
     * Returns the maxCodeLen.
     * @return int
     */
    public int getMaxCodeLen() { return this.maxCodeLen; }

    /**
     * Sets the maxCodeLen.
     * @param maxCodeLen The maxCodeLen to set
     */
    public void setMaxCodeLen(int maxCodeLen) { this.maxCodeLen = maxCodeLen; }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久亚洲蜜桃| 午夜电影久久久| 亚洲高清一区二区三区| 国产真实乱偷精品视频免| 色综合天天综合网天天看片| 日韩视频123| 亚洲精品国产品国语在线app| 精品一区二区三区av| 欧美亚洲一区二区在线| 国产三级一区二区三区| 蜜桃一区二区三区四区| 欧美性受xxxx| 亚洲色大成网站www久久九九| 国产精品一区2区| 日韩欧美不卡在线观看视频| 亚洲综合丁香婷婷六月香| 成人久久视频在线观看| 国产午夜亚洲精品理论片色戒 | 精品处破学生在线二十三| 亚洲一区二区三区精品在线| 91视频国产观看| 中文字幕二三区不卡| 国产老妇另类xxxxx| 日韩欧美成人一区| 免费观看一级特黄欧美大片| 欧美日韩国产一二三| 亚洲在线一区二区三区| 一本到一区二区三区| 日韩一区在线播放| 99久久精品免费看国产| 国产精品国产精品国产专区不片 | 亚洲午夜久久久久| 91丨九色丨尤物| 中文字幕一区二区三区色视频| 国产白丝网站精品污在线入口| 久久婷婷国产综合精品青草| 国产一区二区三区在线观看免费 | 欧美电视剧在线观看完整版| 美女一区二区三区| 日韩一本二本av| 美脚の诱脚舐め脚责91| 精品少妇一区二区三区在线视频 | 亚洲国产中文字幕| 欧美区在线观看| 日本不卡免费在线视频| 日韩免费成人网| 国产黄人亚洲片| 中文字幕在线播放不卡一区| 99久久久免费精品国产一区二区 | 国产视频911| 本田岬高潮一区二区三区| 中文字幕一区二区视频| 在线看不卡av| 日韩电影免费一区| 久久综合色天天久久综合图片| 国产精品一区一区| 国产精品第五页| 欧美色图12p| 蜜臀久久久99精品久久久久久| 精品久久久久久久久久久院品网| 国内偷窥港台综合视频在线播放| 亚洲国产精品高清| 欧美三级电影在线观看| 美女视频网站久久| 欧美国产精品劲爆| 欧美日韩亚洲综合| 国产一区二区三区视频在线播放| 中文无字幕一区二区三区| 一本久久综合亚洲鲁鲁五月天| 五月天久久比比资源色| 久久久美女毛片| 91国偷自产一区二区使用方法| 丝袜美腿亚洲色图| 亚洲欧美综合网| 日韩免费成人网| 色中色一区二区| 狠狠色狠狠色综合| 亚洲一二三区不卡| 国产午夜精品在线观看| 欧美人体做爰大胆视频| 99这里都是精品| 韩国女主播一区| 亚洲高清久久久| 国产精品色哟哟网站| 日韩欧美在线综合网| 色一情一乱一乱一91av| 国产精品系列在线观看| 丝袜亚洲另类丝袜在线| 亚洲欧美视频在线观看| 久久久精品2019中文字幕之3| 欧美日韩综合在线免费观看| 成人黄色软件下载| 六月丁香综合在线视频| 亚洲综合区在线| 国产精品的网站| 国产日韩精品一区| 精品国产髙清在线看国产毛片 | 伊人开心综合网| 国产女人aaa级久久久级| 欧美xxx久久| 91精品国产综合久久国产大片| 丰满岳乱妇一区二区三区 | 亚洲激情成人在线| 中文成人综合网| 国产精品丝袜久久久久久app| 51精品视频一区二区三区| 91麻豆福利精品推荐| 成人av动漫网站| 成人免费毛片高清视频| 国产在线精品视频| 精品一区中文字幕| 久久激情五月婷婷| 卡一卡二国产精品| 久久99精品久久只有精品| 美美哒免费高清在线观看视频一区二区| 亚洲无人区一区| 一区二区三区成人| 亚洲一二三四区不卡| 亚洲影院免费观看| 亚洲国产精品久久久久秋霞影院 | 欧美三级视频在线播放| 色欲综合视频天天天| 欧美午夜电影网| 69精品人人人人| 欧美一卡2卡三卡4卡5免费| 91精品国产福利| 欧美精品一区二区高清在线观看| 久久人人爽爽爽人久久久| 欧美精品一区二区三区蜜臀| 欧美激情一区二区三区蜜桃视频| 国产精品丝袜在线| 一区二区三区免费在线观看| 午夜精品视频在线观看| 久久精品国产免费| 国产高清久久久| 色综合色狠狠综合色| 91精品国产欧美一区二区成人| 7777精品伊人久久久大香线蕉经典版下载 | 狠狠色丁香婷综合久久| 精品一区二区三区在线播放| 国产精品1024| 91久久线看在观草草青青| 欧美日高清视频| 2020国产精品自拍| 亚洲少妇中出一区| 亚洲va国产天堂va久久en| 精品一区二区三区蜜桃| av中文字幕在线不卡| 欧美精品精品一区| 国产农村妇女精品| 亚洲一区影音先锋| 国精品**一区二区三区在线蜜桃| 成人午夜电影网站| 欧美丰满少妇xxxbbb| 久久久亚洲精华液精华液精华液| 亚洲日本电影在线| 精品一区二区三区免费播放| 91网址在线看| 精品日韩99亚洲| 亚洲精品成a人| 国产在线看一区| 在线观看一区日韩| 国产亚洲欧洲997久久综合| 亚洲国产精品久久人人爱蜜臀 | www.av精品| 在线播放视频一区| 中文字幕在线观看一区| 日本不卡视频在线观看| 色偷偷久久一区二区三区| 2023国产精品| 亚洲第一电影网| 99re热这里只有精品视频| 欧美tk丨vk视频| 性久久久久久久久久久久| 99re热视频精品| 中文av一区二区| 国产一区二区三区免费| 欧美日韩一区二区三区视频| 国产精品乱码妇女bbbb| 久久er精品视频| 欧美喷潮久久久xxxxx| 亚洲色图视频网| 丁香婷婷综合网| 26uuu久久综合| 久久99精品久久久久久久久久久久 | 欧美成人福利视频| 亚洲国产一区二区视频| 色婷婷综合久久久久中文| 成人aa视频在线观看| 久久精品国产一区二区| 欧美日韩精品一区二区三区蜜桃| 亚洲色图制服丝袜| 国产成人精品三级| 久久亚洲影视婷婷| 久久国内精品视频| 日韩欧美综合在线| 老色鬼精品视频在线观看播放| 91精品国产欧美一区二区成人| 视频一区二区不卡| 欧美女孩性生活视频|