diff options
author | StefanVukovic99 <stefanvukovic44@gmail.com> | 2024-01-20 02:25:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-20 01:25:23 +0000 |
commit | 2b87c919bcd879c7f356308bc522b95f33e35f3b (patch) | |
tree | 1301aa8bf3d9b91ad96bbe9372a66dceba190346 /types/ext | |
parent | 48f1d012ad5045319d4e492dfbefa39da92817b2 (diff) |
Dictionary deinflections (#503)
* wip
* wip
* fix v3
* wip
* fix tests
* fix maxitems
* hide deinflection definitions
* fix anki template
* undo unnecessary change
* delete console.log
* refactor
* add set false to handlebars
* lint
* fix tests
* fix comments
* fix
* use Map in areArraysEqualIgnoreOrder
* move inflection source icons to css
* lint
* improve naming
* fix tests
* add test
* typescript
* use for of
* wip
* comments
* anki template upgrade
* update descriptions
Diffstat (limited to 'types/ext')
-rw-r--r-- | types/ext/anki-templates.d.ts | 2 | ||||
-rw-r--r-- | types/ext/dictionary-data.d.ts | 9 | ||||
-rw-r--r-- | types/ext/dictionary.d.ts | 15 | ||||
-rw-r--r-- | types/ext/settings.d.ts | 1 | ||||
-rw-r--r-- | types/ext/translation-internal.d.ts | 5 | ||||
-rw-r--r-- | types/ext/translation.d.ts | 4 |
6 files changed, 30 insertions, 6 deletions
diff --git a/types/ext/anki-templates.d.ts b/types/ext/anki-templates.d.ts index 098873e6..7348b571 100644 --- a/types/ext/anki-templates.d.ts +++ b/types/ext/anki-templates.d.ts @@ -172,7 +172,7 @@ export type TermDictionaryEntry = { source: string | null; rawSource: string | null; sourceTerm?: string | null; - reasons: string[]; + inflectionRuleChainCandidates: Dictionary.InflectionRuleChainCandidate[]; score: number; isPrimary?: boolean; readonly sequence: number; diff --git a/types/ext/dictionary-data.d.ts b/types/ext/dictionary-data.d.ts index 0e0edd5c..82e0f00d 100644 --- a/types/ext/dictionary-data.d.ts +++ b/types/ext/dictionary-data.d.ts @@ -90,6 +90,11 @@ export type KanjiV3 = [ ]; export type TermGlossary = ( + TermGlossaryContent | + TermGlossaryDeinflection +); + +export type TermGlossaryContent = ( TermGlossaryString | TermGlossaryText | TermGlossaryImage | @@ -100,6 +105,10 @@ export type TermGlossaryString = string; export type TermGlossaryText = {type: 'text', text: string}; export type TermGlossaryImage = {type: 'image'} & TermImage; export type TermGlossaryStructuredContent = {type: 'structured-content', content: StructuredContent.Content}; +export type TermGlossaryDeinflection = [ + uninflected: string, + inflectionRuleChain: string[], +]; export type TermImage = StructuredContent.ImageElementBase & { // Compatibility properties diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index 7c348e7f..ed7769a9 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -208,9 +208,9 @@ export type TermDictionaryEntry = { */ isPrimary: boolean; /** - * A list of inflections that was applied to get the term. + * Ways that a looked-up word might be an inflected form of this term. */ - inflections: string[]; + inflectionRuleChainCandidates: InflectionRuleChainCandidate[]; /** * A score for the dictionary entry. */ @@ -253,6 +253,15 @@ export type TermDictionaryEntry = { frequencies: TermFrequency[]; }; +export type InflectionRuleChainCandidate = { + source: InflectionSource; + inflectionRules: InflectionRuleChain; +}; + +export type InflectionRuleChain = string[]; + +export type InflectionSource = 'algorithm' | 'dictionary' | 'both'; + /** * A term headword is a combination of a term, reading, and auxiliary information. */ @@ -337,7 +346,7 @@ export type TermDefinition = { /** * The definition entries. */ - entries: DictionaryData.TermGlossary[]; + entries: DictionaryData.TermGlossaryContent[]; }; /** diff --git a/types/ext/settings.d.ts b/types/ext/settings.d.ts index b95691b2..a3d3e141 100644 --- a/types/ext/settings.d.ts +++ b/types/ext/settings.d.ts @@ -259,6 +259,7 @@ export type DictionaryOptions = { allowSecondarySearches: boolean; definitionsCollapsible: DictionaryDefinitionsCollapsible; partsOfSpeechFilter: boolean; + useDeinflections: boolean; }; export type ParsingOptions = { diff --git a/types/ext/translation-internal.d.ts b/types/ext/translation-internal.d.ts index 5845b45d..15456e41 100644 --- a/types/ext/translation-internal.d.ts +++ b/types/ext/translation-internal.d.ts @@ -16,6 +16,7 @@ */ import type * as DictionaryDatabase from './dictionary-database'; +import type * as Dictionary from './dictionary'; import type * as Translation from './translation'; export type TextDeinflectionOptions = [ @@ -52,7 +53,7 @@ export enum DeinflectionRuleFlags { export type Deinflection = { term: string; rules: DeinflectionRuleFlags; - reasons: string[]; + reasons: Dictionary.InflectionRuleChain; }; export type DatabaseDeinflection = { @@ -60,6 +61,6 @@ export type DatabaseDeinflection = { transformedText: string; deinflectedText: string; rules: DeinflectionRuleFlags; - reasons: string[]; + inflectionRuleChainCandidates: Dictionary.InflectionRuleChainCandidate[]; databaseEntries: DictionaryDatabase.TermEntry[]; }; diff --git a/types/ext/translation.d.ts b/types/ext/translation.d.ts index d597c006..db0cf02f 100644 --- a/types/ext/translation.d.ts +++ b/types/ext/translation.d.ts @@ -177,6 +177,10 @@ export type FindTermDictionary = { * Whether this dictionary's part of speech rules should be used to filter results. */ partsOfSpeechFilter: boolean; + /** + * Whether to use the deinflections from this dictionary. + */ + useDeinflections: boolean; }; export type TermEnabledDictionaryMap = Map<string, FindTermDictionary>; |