with all words thing

This commit is contained in:
adueck 2023-01-19 22:22:37 +05:00
parent 8788abf5d5
commit eeb35bf489
2 changed files with 9 additions and 2 deletions

View File

@ -30,6 +30,7 @@ const dictionaryFilename = "dict";
const dictionaryInfoFilename = "dict-info"; const dictionaryInfoFilename = "dict-info";
const hunspellAffFileFilename = "ps_AFF.aff"; const hunspellAffFileFilename = "ps_AFF.aff";
const hunspellDicFileFilename = "ps_AFF.dic"; const hunspellDicFileFilename = "ps_AFF.dic";
const allWordsJsonFilename = "all-words.json";
const url = `${baseUrl}${dictionaryFilename}`; const url = `${baseUrl}${dictionaryFilename}`;
const infoUrl = `${baseUrl}${dictionaryInfoFilename}`; const infoUrl = `${baseUrl}${dictionaryInfoFilename}`;
@ -60,20 +61,21 @@ export default async function publish(): Promise<PublishDictionaryResponse> {
} }
uploadDictionaryToStorage(dictionary).catch(console.error); uploadDictionaryToStorage(dictionary).catch(console.error);
// TODO: make this async and run after publish response // TODO: make this async and run after publish response
doHunspell(entries).catch(console.error); doHunspellEtc(entries).catch(console.error);
return { return {
ok: true, ok: true,
info: dictionary.info info: dictionary.info
}; };
} }
async function doHunspell(entries: T.DictionaryEntry[]) { async function doHunspellEtc(entries: T.DictionaryEntry[]) {
const wordlistResponse = getWordList(entries); const wordlistResponse = getWordList(entries);
if (!wordlistResponse.ok) { if (!wordlistResponse.ok) {
throw new Error(JSON.stringify(wordlistResponse.errors)); throw new Error(JSON.stringify(wordlistResponse.errors));
} }
const hunspell = makeHunspell(wordlistResponse.wordlist); const hunspell = makeHunspell(wordlistResponse.wordlist);
await uploadHunspellToStorage(hunspell); await uploadHunspellToStorage(hunspell);
await uploadAllWordsToStoarage(wordlistResponse.wordlist)
} }
/** /**
@ -232,6 +234,10 @@ async function uploadHunspellToStorage(wordlist: {
]); ]);
} }
async function uploadAllWordsToStoarage(words: string[]) {
await upload(JSON.stringify({words}), allWordsJsonFilename)
}
async function uploadDictionaryToStorage(dictionary: T.Dictionary) { async function uploadDictionaryToStorage(dictionary: T.Dictionary) {
const dictionaryBuffer = writeDictionary(dictionary); const dictionaryBuffer = writeDictionary(dictionary);
const dictionaryInfoBuffer = writeDictionaryInfo(dictionary.info); const dictionaryInfoBuffer = writeDictionaryInfo(dictionary.info);

View File

@ -44,6 +44,7 @@ const ScriptToPhonetics = () => {
rows={4} rows={4}
value={text} value={text}
onChange={e => setText(e.target.value)} onChange={e => setText(e.target.value)}
dir="rtl"
/> />
</div> </div>
<div> <div>