Skip to content

Commit

Permalink
add fuzzy-soundex encoded json
Browse files Browse the repository at this point in the history
  • Loading branch information
dongyuwei committed Nov 24, 2023
1 parent bdddaa9 commit c04278d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions dictionary/encode-by-fuzzy-soundex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const fs = require("fs");
const phonex = require("talisman/phonetics/fuzzy-soundex.js");
const words = require("./words_with_frequency_and_translation_and_ipa.json");

const map = {};
for (let key in words) {
if (key.length > 3) {
const encoded = phonex(key);
const list = map[encoded] || [];
list.push(key);
map[encoded] = list;
}
}

for (let code in map) {
map[code] = map[code]
.sort((a, b) => {
return words[b].frequency - words[a].frequency;
})
.slice(0, 30);
}

fs.writeFileSync("./fuzzy_soundex_encoded_words.json", JSON.stringify(map), "utf-8");
1 change: 1 addition & 0 deletions dictionary/fuzzy_soundex_encoded_words.json

Large diffs are not rendered by default.

0 comments on commit c04278d

Please sign in to comment.