From cfa33c8f5d77b2365abc3715c31d18f52135897b Mon Sep 17 00:00:00 2001 From: James Maa Date: Mon, 24 Jun 2024 09:56:02 -0700 Subject: More Spanish transforms (#1100) * Preterite and spanish bench * More spanish forms * Rename --- benches/spanish-language-transformer.bench.js | 140 ++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 benches/spanish-language-transformer.bench.js (limited to 'benches/spanish-language-transformer.bench.js') diff --git a/benches/spanish-language-transformer.bench.js b/benches/spanish-language-transformer.bench.js new file mode 100644 index 00000000..8dc60ceb --- /dev/null +++ b/benches/spanish-language-transformer.bench.js @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2023-2024 Yomitan Authors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import {bench, describe} from 'vitest'; +import {spanishTransforms} from '../ext/js/language/es/spanish-transforms.js'; +import {LanguageTransformer} from '../ext/js/language/language-transformer.js'; + +const languageTransformer = new LanguageTransformer(); +languageTransformer.addDescriptor(spanishTransforms); + +describe('spanish language transformer', () => { + describe('basic tests', () => { + const nounInflections = [ + 'gatos', + 'sofás', + 'tisús', + 'tisúes', + 'autobuses', + 'ciudades', + 'clics', + 'síes', + 'zigzags', + 'luces', + 'canciones', + ]; + + const verbPresentInflections = [ + 'hablo', + 'hablas', + 'habla', + 'hablamos', + 'habláis', + 'hablan', + 'como', + 'comes', + 'come', + 'comemos', + 'coméis', + 'comen', + 'vivo', + 'vives', + 'vive', + 'vivimos', + 'vivís', + 'viven', + 'tengo', + 'tienes', + 'tiene', + 'tenemos', + 'tenéis', + 'tienen', + 'exijo', + 'extingo', + 'escojo', + 'quepo', + 'caigo', + 'conozco', + 'doy', + 'hago', + 'pongo', + 'sé', + 'salgo', + 'traduzco', + 'traigo', + 'valgo', + 'veo', + 'soy', + 'estoy', + 'voy', + 'he', + ]; + + const verbPreteriteInflections = [ + 'hablé', + 'hablaste', + 'habló', + 'hablamos', + 'hablasteis', + 'hablaron', + 'comí', + 'comiste', + 'comió', + 'comimos', + 'comisteis', + 'comieron', + 'viví', + 'viviste', + 'vivió', + 'vivimos', + 'vivisteis', + 'vivieron', + 'tuve', + 'tuviste', + 'tuvo', + 'tuvimos', + 'tuvisteis', + 'tuvieron', + 'exigí', + 'extinguí', + 'escogí', + 'cupe', + 'caí', + 'conocí', + 'di', + 'hice', + 'puse', + 'supe', + 'salí', + 'traduje', + 'traje', + 'valí', + 'vi', + 'fui', + 'estuve', + 'fui', + 'hube', + ]; + + const basicTransformations = [...nounInflections, ...verbPresentInflections, ...verbPreteriteInflections]; + bench(`spanish transformations (n=${basicTransformations.length})`, () => { + for (const transform of basicTransformations) { + languageTransformer.transform(transform); + } + }); + }); +}); -- cgit v1.2.3