CognxSafeTrack
Claude Sonnet 4.6
refactor(debt): resolve all 10 technical debt items from audit
a966957 Download apps/whatsapp-worker/src/services/normalization.ts from safetrack/edtech: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/spaces/safetrack/edtech/resolve/main/apps/whatsapp-worker/src/services/normalization.ts
- Command line
-
hf download hf://spaces/safetrack/edtech/apps/whatsapp-worker/src/services/normalization.ts
-
curl -L -o normalization.ts https://huggingface.co/spaces/safetrack/edtech/resolve/main/apps/whatsapp-worker/src/services/normalization.ts
1 kB
| import { prisma } from './prisma'; | |
| import { logger } from '../logger'; | |
| import { redisForBullMQ as connection } from '../lib/redis'; | |
| const CACHE_KEY = 'normalization:rules:wolof'; | |
| export const normalizationService = { | |
| /** | |
| * Get all normalization rules for a language | |
| */ | |
| async getRules(language: string = 'WOLOF'): Promise<Record<string, string>> { | |
| const cacheKey = `${CACHE_KEY}:${language}`; | |
| try { | |
| const cached = await connection.get(cacheKey); | |
| if (cached) return JSON.parse(cached); | |
| } catch (err) { | |
| logger.error({ err }, '[NORMALIZATION] Redis get error'); | |
| } | |
| const rules = await prisma.normalizationRule.findMany({ | |
| where: { language } | |
| }); | |
| const ruleMap: Record<string, string> = {}; | |
| rules.forEach((r: { original: string; replacement: string }) => { | |
| ruleMap[r.original.toLowerCase()] = r.replacement; | |
| }); | |
| return ruleMap; | |
| } | |
| }; | |