Pop-up dictionary browser extension for language learning. Successor to Yomichan. (PERSONAL FORK)
at lambda-fork/main 85 lines 2.9 kB view raw
1/* 2 * Copyright (C) 2023-2025 Yomitan Authors 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18import type * as DictionaryDatabase from './dictionary-database'; 19import type * as Dictionary from './dictionary'; 20import type * as Translation from './translation'; 21import type * as Language from './language'; 22 23export type TextDeinflectionOptions = [ 24 textReplacements: Translation.FindTermsTextReplacement[] | null, 25 halfWidth: boolean, 26 numeric: boolean, 27 alphabetic: boolean, 28 katakana: boolean, 29 hiragana: boolean, 30 emphatic: [collapseEmphatic: boolean, collapseEmphaticFull: boolean], 31]; 32 33export type TextDeinflectionOptionsArrays = [ 34 textReplacements: (Translation.FindTermsTextReplacement[] | null)[], 35 halfWidth: boolean[], 36 numeric: boolean[], 37 alphabetic: boolean[], 38 katakana: boolean[], 39 hiragana: boolean[], 40 emphatic: [collapseEmphatic: boolean, collapseEmphaticFull: boolean][], 41]; 42 43export type TextProcessorRuleChainCandidate = string[]; 44 45export type VariantAndTextProcessorRuleChainCandidatesMap = Map<string, TextProcessorRuleChainCandidate[]>; 46 47export type TermDictionaryEntry = Omit<Dictionary.TermDictionaryEntry, 'inflectionRuleChainCandidates'> & { 48 inflectionRuleChainCandidates: InflectionRuleChainCandidate[]; 49 textProcessorRuleChainCandidates: TextProcessorRuleChainCandidate[]; 50}; 51 52export type InflectionRuleChainCandidate = { 53 source: Dictionary.InflectionSource; 54 inflectionRules: string[]; 55}; 56 57export type DatabaseDeinflection = { 58 originalText: string; 59 transformedText: string; 60 deinflectedText: string; 61 conditions: number; 62 textProcessorRuleChainCandidates: TextProcessorRuleChainCandidate[]; 63 inflectionRuleChainCandidates: InflectionRuleChainCandidate[]; 64 databaseEntries: DictionaryDatabase.TermEntry[]; 65}; 66 67export type DictionaryEntryGroup = { 68 ids: Set<number>; 69 dictionaryEntries: TermDictionaryEntry[]; 70}; 71 72export type TextProcessorMap = Map< 73 string, 74 { 75 textPreprocessors: Language.TextProcessorWithId[]; 76 textPostprocessors: Language.TextProcessorWithId[]; 77 } 78>; 79 80export type ReadingNormalizerMap = Map< 81 string, 82 Language.ReadingNormalizer 83>; 84 85export type TextCache = Map<string, Map<string, string[]>>;