Created
August 30, 2023 00:46
-
-
Save kabeer11000/e0806405f7066278a0c8935f792facff to your computer and use it in GitHub Desktop.
Scrabble Bi-Grams based word prediction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const validWords = ["dog", "dough", "doggy", "doodle", "dig", "door"]; | |
const bigrams = ["do", "og"]; // Example bigram array | |
function generateValidWordsFromBigrams(bigrams, validWords) { | |
const validGeneratedWords = []; | |
for (const word of validWords) { | |
const isValid = bigrams.every(bigram => word.includes(bigram)); | |
if (isValid) { | |
validGeneratedWords.push(word); | |
} | |
} | |
return validGeneratedWords; | |
} | |
// filter words by rack | |
const validGeneratedWords = generateValidWordsFromBigrams(bigrams, validWords); | |
console.log(validGeneratedWords); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment