-
Notifications
You must be signed in to change notification settings - Fork 3
/
dict.js
58 lines (55 loc) · 2.42 KB
/
dict.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function search(pat,searchmode,callback){
console.log(pat);
generateCand(pat, searchmode, callback, null, "", "");
}
function generateCand(pat, searchmode, callback, connection, foundword, foundpat){
// これまでマッチした文字列がfoundword,foundpatに入っている
var d = (connection ? connectionLink[connection] : keyLink[pat.charCodeAt(0)]);
while(d != null && d != undefined){
if(pat == dictData[d][0]){ // 完全一致
callback(foundword+dictData[d][1], foundpat+dictData[d][1], dictData[d][3] /* outConnection */);
}
else if(dictData[d][0].startsWith(pat)){ // 先頭一致
if(searchmode == 0){
callback(foundword+dictData[d][1], foundpat+dictData[d][0], dictData[d][3]);
}
}
// else if(_searchmode == 0 && pat.startsWith(dictData[d][0])){ // connectionがあるかも
else if(pat.startsWith(dictData[d][0])){ // connectionがあるかも
var restpat = pat.substring(dictData[d][0].length,pat.length);
if(dictData[d][3] != 0){
generateCand(restpat, searchmode, callback, dictData[d][3], foundword+dictData[d][1], foundpat+dictData[d][0]);
}
}
d = (connection ? dictData[d][5] : dictData[d][4]);
}
}
function generateCandxxx(pat, searchmode, callback, connection, foundword, foundpat){
// これまでマッチした文字列がfoundword,foundpatに入っている
var d = (connection ? connectionLink[connection] : keyLink[pat.charCodeAt(0)]);
console.log("pat = " + pat);
console.log("d ==== " + d);
if(d != null && d != undefined){
console.log("-----");
console.log(dictData[d]);
}
return;
while(d != null && d != undefined){
if(pat == dictData[d].pat){ // 完全一致
callback(foundword+dictData[d].word, foundpat+dictData[d].word, dictData[d].out /* outConnection */);
}
else if(dictData[d].pat.startsWith(pat)){ // 先頭一致
if(searchmode == 0){
callback(foundword+dictData[d].word, foundpat+dictData[d].pat, dictData[d].out);
}
}
// else if(_searchmode == 0 && pat.startsWith(dictData[d][0])){ // connectionがあるかも
else if(pat.startsWith(dictData[d].pat)){ // connectionがあるかも
var restpat = pat.substring(dictData[d].pat.length,pat.length);
if(dictData[d].out != 0){
generateCand(restpat, searchmode, callback, dictData[d].out, foundword+dictData[d].word, foundpat+dictData[d].pat);
}
}
d = (connection ? dictData[d].clink : dictData[d].klink);
}
}