From ea48bfa630f48f47122f450cd31697e79468b238 Mon Sep 17 00:00:00 2001 From: Inga Date: Sun, 14 Jan 2024 16:22:45 +0000 Subject: [PATCH] fixed words extraction --- src/build-scripts/oooThesaurusParser.test.ts | 10 +++++++++- src/build-scripts/oooThesaurusParser.ts | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/build-scripts/oooThesaurusParser.test.ts b/src/build-scripts/oooThesaurusParser.test.ts index 983fa52..617fbb2 100644 --- a/src/build-scripts/oooThesaurusParser.test.ts +++ b/src/build-scripts/oooThesaurusParser.test.ts @@ -7,5 +7,13 @@ void t.test('extractWordsFromFile', async (t) => { new URL('../../build-resources/th-en-x-basic.dat', import.meta.url), ); //console.log(words); - t.equal(words.length, 12371); + t.equal(words.length, 24691); + t.equal(words.includes('afterthought'), true); + t.equal(words.includes('airplane'), true); + t.equal(words.includes('another'), true); + t.equal(words.includes('anybody'), true); + t.equal(words.includes('anyhow'), true); + t.equal(words.includes('anyone'), true); + t.equal(words.includes('anything'), true); + t.equal(words.includes('anywhere'), true); }); diff --git a/src/build-scripts/oooThesaurusParser.ts b/src/build-scripts/oooThesaurusParser.ts index ef52e54..3673c64 100644 --- a/src/build-scripts/oooThesaurusParser.ts +++ b/src/build-scripts/oooThesaurusParser.ts @@ -29,7 +29,7 @@ const extractWordsFromThesaurus = (thesaurus: string): string[] => { chunks .filter((chunk) => chunk.length) .map((chunk) => chunk[0]?.split('|')?.[0]), - ).filter(WORD_REGEX.test.bind(WORD_REGEX)); + ).filter((maybeWord) => !!maybeWord.match(WORD_REGEX)); }; export const extractWordsFromFile = async (