Skip to content

Commit

Permalink
Update words.ts
Browse files Browse the repository at this point in the history
Ignores specific words that seem like English despite being Igbo
  • Loading branch information
ijemmao authored Oct 19, 2023
1 parent 4bda256 commit 90817f0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/controllers/words.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Express, LegacyWord } from '../types';
import { WordResponseData } from './types';

const isEnglish = isWord('american-english');
const IGNORE_ENGLISH_WORDS = ['ego'];

/* Gets words from JSON dictionary */
export const getWordData: Express.MiddleWare = (req, res, next) => {
Expand Down Expand Up @@ -60,7 +61,8 @@ const getWordsFromDatabase: Express.MiddleWare = async (req, res, next) => {
filters,
};
let responseData: WordResponseData = { words: [], contentLength: 0 };
const isSearchWordEnglish = isEnglish.check(searchWord) && !!searchWord;
const isSearchWordEnglish =
isEnglish.check(searchWord) && !!searchWord && !IGNORE_ENGLISH_WORDS.includes(searchWord);
if (hasQuotes || isSearchWordEnglish) {
responseData = await searchWordUsingEnglish({
redisClient,
Expand Down

0 comments on commit 90817f0

Please sign in to comment.