scrabble-solver
Version:
Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.
27 lines (22 loc) • 865 B
text/typescript
import { Locale } from '@scrabble-solver/types';
import { english, french, german, persian, polish, romanian, spanish, turkish } from './languages';
import { normalizeDefinition, unique } from './lib';
import { ParsingResult } from './types';
const parsePerLocale: Record<Locale, (html: string) => ParsingResult> = {
[]: german.parse,
[]: english.parse,
[]: english.parse,
[]: spanish.parse,
[]: persian.parse,
[]: french.parse,
[]: polish.parse,
[]: romanian.parse,
[]: turkish.parse,
};
export const parse = (locale: Locale, html: string): ParsingResult => {
const { definitions, exists } = parsePerLocale[locale](html);
return {
definitions: unique(definitions.map(normalizeDefinition).filter(Boolean)),
exists,
};
};