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

模糊搜索演算法

發布時間: 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-09-18 12:01:35 瀏覽:525
絕地求生和賽博朋克2077哪個吃配置 發布:2025-09-18 11:35:20 瀏覽:165
亞索腳本秒風 發布:2025-09-18 11:35:07 瀏覽:433
sql表的復制 發布:2025-09-18 11:02:25 瀏覽:68
三位密碼鎖忘記密碼如何重置 發布:2025-09-18 10:21:52 瀏覽:186
linux怎麼編譯c文件 發布:2025-09-18 09:55:16 瀏覽:305
python安裝後無法運行 發布:2025-09-18 09:45:57 瀏覽:239
安卓手機怎麼剪輯音樂 發布:2025-09-18 09:44:16 瀏覽:784
伺服器地址修改在哪找 發布:2025-09-18 09:42:41 瀏覽:444
sntp伺服器地址 發布:2025-09-18 09:28:36 瀏覽:555