From 7d6947338ad261975133df404174414ff2eabac9 Mon Sep 17 00:00:00 2001 From: wilson Date: Tue, 31 Mar 2026 07:22:43 +0100 Subject: [PATCH] Add language formatter and spaCy types --- frontend/src/lib/formatters/formatLanguage.ts | 9 +++++++++ frontend/src/lib/formatters/index.ts | 1 + frontend/src/lib/spacy/types.ts | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 frontend/src/lib/formatters/formatLanguage.ts create mode 100644 frontend/src/lib/formatters/index.ts create mode 100644 frontend/src/lib/spacy/types.ts diff --git a/frontend/src/lib/formatters/formatLanguage.ts b/frontend/src/lib/formatters/formatLanguage.ts new file mode 100644 index 0000000..c162f3e --- /dev/null +++ b/frontend/src/lib/formatters/formatLanguage.ts @@ -0,0 +1,9 @@ +const languageNames: Record = { + en: 'English', + fr: 'French', + es: 'Spanish', + it: 'Italian', + de: 'German' +}; + +export const formatLanguage = (code: string) => languageNames[code] ?? code.toUpperCase(); diff --git a/frontend/src/lib/formatters/index.ts b/frontend/src/lib/formatters/index.ts new file mode 100644 index 0000000..87f8b84 --- /dev/null +++ b/frontend/src/lib/formatters/index.ts @@ -0,0 +1 @@ +export { formatLanguage } from './formatLanguage'; diff --git a/frontend/src/lib/spacy/types.ts b/frontend/src/lib/spacy/types.ts new file mode 100644 index 0000000..0a2bad6 --- /dev/null +++ b/frontend/src/lib/spacy/types.ts @@ -0,0 +1,19 @@ +export interface PartsOfSpeechData { + language: string; + sentences: { + text: string; + tokens: PartOfSpeechToken[]; + }[]; +} + +export interface PartOfSpeechToken { + dep: string; + pos: string; + tag: string; + text: string; + type: null | string; + lemma: string; + is_stop: boolean; + is_alpha: boolean; + is_punct: boolean; +}