aboutsummaryrefslogtreecommitdiff
path: root/ext/data
diff options
context:
space:
mode:
authorStefanVukovic99 <stefanvukovic44@gmail.com>2024-01-20 02:25:23 +0100
committerGitHub <noreply@github.com>2024-01-20 01:25:23 +0000
commit2b87c919bcd879c7f356308bc522b95f33e35f3b (patch)
tree1301aa8bf3d9b91ad96bbe9372a66dceba190346 /ext/data
parent48f1d012ad5045319d4e492dfbefa39da92817b2 (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 'ext/data')
-rw-r--r--ext/data/schemas/dictionary-term-bank-v3-schema.json20
-rw-r--r--ext/data/schemas/options-schema.json7
-rw-r--r--ext/data/templates/anki-field-templates-upgrade-v24.handlebars52
-rw-r--r--ext/data/templates/default-anki-field-templates.handlebars22
4 files changed, 94 insertions, 7 deletions
diff --git a/ext/data/schemas/dictionary-term-bank-v3-schema.json b/ext/data/schemas/dictionary-term-bank-v3-schema.json
index 8243f2a7..066229c3 100644
--- a/ext/data/schemas/dictionary-term-bank-v3-schema.json
+++ b/ext/data/schemas/dictionary-term-bank-v3-schema.json
@@ -400,7 +400,7 @@
},
{
"type": "string",
- "description": "String of space-separated rule identifiers for the definition which is used to validate delinflection. Valid rule identifiers are: v1: ichidan verb; v5: godan verb; vs: suru verb; vk: kuru verb; adj-i: i-adjective. An empty string corresponds to words which aren't inflected, such as nouns."
+ "description": "String of space-separated rule identifiers for the definition which is used to validate deinflection. An empty string should be used for words which aren't inflected."
},
{
"type": "number",
@@ -535,6 +535,24 @@
}
}
]
+ },
+ {
+ "type": "array",
+ "description": "Deinflection of the term to an uninflected term.",
+ "items": [
+ {
+ "type": "string",
+ "description": "The uninflected term."
+ },
+ {
+ "type": "array",
+ "description": "A chain of inflection rules that produced the inflected term",
+ "items": {
+ "type": "string",
+ "description": "A single inflection rule."
+ }
+ }
+ ]
}
]
}
diff --git a/ext/data/schemas/options-schema.json b/ext/data/schemas/options-schema.json
index 8cf00400..24f3a6b0 100644
--- a/ext/data/schemas/options-schema.json
+++ b/ext/data/schemas/options-schema.json
@@ -823,7 +823,8 @@
"enabled",
"allowSecondarySearches",
"definitionsCollapsible",
- "partsOfSpeechFilter"
+ "partsOfSpeechFilter",
+ "useDeinflections"
],
"properties": {
"name": {
@@ -850,6 +851,10 @@
"partsOfSpeechFilter": {
"type": "boolean",
"default": true
+ },
+ "useDeinflections": {
+ "type": "boolean",
+ "default": true
}
}
}
diff --git a/ext/data/templates/anki-field-templates-upgrade-v24.handlebars b/ext/data/templates/anki-field-templates-upgrade-v24.handlebars
new file mode 100644
index 00000000..2288737c
--- /dev/null
+++ b/ext/data/templates/anki-field-templates-upgrade-v24.handlebars
@@ -0,0 +1,52 @@
+{{#*inline "phonetic-transcriptions"}}
+ {{~#if (op ">" definition.phoneticTranscriptions.length 0)~}}
+ <ul>
+ {{~#each definition.phoneticTranscriptions~}}
+ {{~#each phoneticTranscriptions~}}
+ <li>
+ {{~set "any" false~}}
+ {{~#each tags~}}
+ {{~#if (get "any")}}, {{else}}<i>({{/if~}}
+ {{name}}
+ {{~set "any" true~}}
+ {{~/each~}}
+ {{~#if (get "any")}})</i> {{/if~}}
+ {{ipa~}}
+ </li>
+ {{~/each~}}
+ {{~/each~}}
+ </ul>
+ {{~/if~}}
+{{/inline}}
+
+{{<<<<<<<}}
+{{#*inline "conjugation"}}
+ {{~#if (op ">" definition.inflectionRuleChainCandidates.length 0)~}}
+ {{~set "multiple" false~}}
+ {{~#if (op ">" definition.inflectionRuleChainCandidates.length 1)~}}
+ {{~set "multiple" true~}}
+ {{~/if~}}
+ {{~#if (get "multiple")~}}<ul>{{/if~}}
+ {{~#each definition.inflectionRuleChainCandidates~}}
+ {{~#if (op ">" inflectionRules.length 0)~}}
+ {{~#if (get "multiple")~}}<li>{{/if~}}
+ {{~#each inflectionRules~}}
+ {{~#if (op ">" @index 0)}} « {{/if~}}
+ {{.}}
+ {{~/each~}}
+ {{~#if (get "multiple")~}}</li>{{/if~}}
+ {{~/if~}}
+ {{~/each~}}
+ {{~#if (get "multiple")~}}</ul>{{/if~}}
+ {{~/if~}}
+{{/inline}}
+{{=======}}
+{{#*inline "conjugation"}}
+ {{~#if definition.reasons~}}
+ {{~#each definition.reasons~}}
+ {{~#if (op ">" @index 0)}} « {{/if~}}
+ {{.}}
+ {{~/each~}}
+ {{~/if~}}
+{{/inline}}
+{{>>>>>>>>}}
diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars
index f23b9d0b..818677ce 100644
--- a/ext/data/templates/default-anki-field-templates.handlebars
+++ b/ext/data/templates/default-anki-field-templates.handlebars
@@ -261,11 +261,23 @@
{{/inline}}
{{#*inline "conjugation"}}
- {{~#if definition.reasons~}}
- {{~#each definition.reasons~}}
- {{~#if (op ">" @index 0)}} « {{/if~}}
- {{.}}
- {{~/each~}}
+ {{~#if (op ">" definition.inflectionRuleChainCandidates.length 0)~}}
+ {{~set "multiple" false~}}
+ {{~#if (op ">" definition.inflectionRuleChainCandidates.length 1)~}}
+ {{~set "multiple" true~}}
+ {{~/if~}}
+ {{~#if (get "multiple")~}}<ul>{{/if~}}
+ {{~#each definition.inflectionRuleChainCandidates~}}
+ {{~#if (op ">" inflectionRules.length 0)~}}
+ {{~#if (get "multiple")~}}<li>{{/if~}}
+ {{~#each inflectionRules~}}
+ {{~#if (op ">" @index 0)}} « {{/if~}}
+ {{.}}
+ {{~/each~}}
+ {{~#if (get "multiple")~}}</li>{{/if~}}
+ {{~/if~}}
+ {{~/each~}}
+ {{~#if (get "multiple")~}}</ul>{{/if~}}
{{~/if~}}
{{/inline}}