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

模糊搜索演算法

發布時間: 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-04-05 20:53:21 瀏覽:692
資料庫設置在哪裡 發布:2025-04-05 20:53:15 瀏覽:955
qq上傳手機視頻 發布:2025-04-05 20:52:15 瀏覽:603
centos7共享文件夾 發布:2025-04-05 20:49:02 瀏覽:560
java導入類 發布:2025-04-05 20:46:36 瀏覽:894
探岳什麼配置有流水型車燈 發布:2025-04-05 20:20:25 瀏覽:861
喵喵試玩腳本 發布:2025-04-05 19:42:08 瀏覽:458
我的世界布吉島伺服器怎麼加材質包 發布:2025-04-05 19:32:27 瀏覽:594
ftp怎麼連接路由 發布:2025-04-05 19:20:52 瀏覽:232
手游腳本商城 發布:2025-04-05 19:08:23 瀏覽:799