Correctly check word boundarie in dictionaries look ups; fix bug in index regeneration.

pull/1656/head
marko 2022-04-05 09:13:56 -04:00
parent 96d7731256
commit 10589f0dc8
2 changed files with 6 additions and 2 deletions

2
apps/bee/ChangeLog Normal file
View File

@ -0,0 +1,2 @@
0.01: New app!
0.02: Fix bug with regenerating index, fix bug in word lookups

View File

@ -31,8 +31,9 @@ function prepareLetterIdx () {
function findWord (w) { function findWord (w) {
"compile" "compile"
var ci = w.charCodeAt(0)-97; var ci = w.charCodeAt(0)-97;
var f = letterIdx[ci].indexOf(w); if (letterIdx[ci].substr(0, w.length)==w) return true;
if (f>=0 && letterIdx[ci][f+w.length]=="\n") return true; var f = letterIdx[ci].indexOf("\n"+w+"\n");
if (f>=0) return true;
return false; return false;
} }
@ -47,6 +48,7 @@ function checkWord (w) {
if (foundWords.indexOf(w)>=0) return false; // already found if (foundWords.indexOf(w)>=0) return false; // already found
if (findWord(w)) { if (findWord(w)) {
foundWords.push(w); foundWords.push(w);
foundWords.sort();
if (w.length==4) score++; if (w.length==4) score++;
else score += w.length; else score += w.length;
if (isPangram(w)) score += 7; if (isPangram(w)) score += 7;