當前位置:首頁 » 操作系統 » 模糊搜索演算法

模糊搜索演算法

發布時間: 2023-06-12 21:19:33

Ⅰ 通訊錄拼音搜索模糊匹配的演算法問題

我用java寫了個簡單的,你可以多測試下:

publicstaticvoidmain(String[]args){

String[]name={"wang","hai","bao"};

String[]tests={"whb","WaHB","wangHB","HB","wh","whbo","whba"};

for(Stringstring:tests){
System.out.println(string+":"+match(name,string));
}

}

publicstaticbooleanmatch(String[]source,Stringinput){

if(source==null||source.length==0||input==null||input.length()==0){
returnfalse;
}

Stringtemp;

//統一轉小寫
input=input.toLowerCase();

for(inti=0;i<source.length;i++){

temp=source[i].toLowerCase();

if(temp==null||temp.length()==0){
returnfalse;
}

//最後一步特殊處理
if(i==source.length-1){
if(temp.startsWith(input)){
returntrue;
}
}

//輸入的字元完全匹配到
if(input.startsWith(temp)){
//匹配到後生成新的字元串
input=input.substring(0,input.indexOf(temp));
//System.out.println("temp:"+temp+" 匹配到後input:"+input);
}

//首字母匹配到
elseif(temp.startsWith(input.substring(0,1))){

input=input.substring(1);
//System.out.println("temp:"+temp+" 匹配到後input:"+input);
}else{
returnfalse;
}

//表示匹配結束
if(input.length()==0){
returntrue;
}

}

returnfalse;
}

Ⅱ 什麼叫模糊控制演算法

模糊控制技術是利用模糊控制演算法控制變頻器的電壓和頻率的一種技術,通過模糊控制技術可使被控電動機的升速時間得到控制,以避免升速過快對電動機使用壽命的影響以及升速過慢而影響工作效率。

熱點內容
解壓玩具怎麼做只用水就可以做 發布:2025-07-01 20:52:56 瀏覽:160
解壓放鬆室 發布:2025-07-01 20:52:43 瀏覽:124
存儲器壞了 發布:2025-07-01 20:46:11 瀏覽:510
iphone怎麼設鎖屏密碼 發布:2025-07-01 20:46:10 瀏覽:620
伺服器如何處理千萬請求 發布:2025-07-01 20:30:53 瀏覽:332
plsqldeveloperjob 發布:2025-07-01 20:29:59 瀏覽:803
剪切文件用什麼配置 發布:2025-07-01 20:23:07 瀏覽:44
酷睿2020主要看哪些配置 發布:2025-07-01 20:23:06 瀏覽:260
sql保存文件 發布:2025-07-01 20:18:52 瀏覽:802
安卓做的登錄頁面怎麼運行 發布:2025-07-01 20:18:48 瀏覽:813