From 90f7d5ba07340413aa7e43c3a0cc038690b32db3 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 26 Mar 2021 19:50:54 -0400 Subject: Add part of speech info (#1561) * Add part of speech info to headwords * Expose parts of speech to Anki template rendering * Expose parts of speech * Update pitch accent categories * Update docs * Add part-of-speech * Update options and tests * Update markers * Update test data --- .../anki-field-templates-upgrade-v10.handlebars | 30 +++++++++++++++++++++ .../default-anki-field-templates.handlebars | 31 ++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 ext/data/templates/anki-field-templates-upgrade-v10.handlebars (limited to 'ext/data/templates') diff --git a/ext/data/templates/anki-field-templates-upgrade-v10.handlebars b/ext/data/templates/anki-field-templates-upgrade-v10.handlebars new file mode 100644 index 00000000..8442a93c --- /dev/null +++ b/ext/data/templates/anki-field-templates-upgrade-v10.handlebars @@ -0,0 +1,30 @@ +{{#*inline "part-of-speech-pretty"}} + {{~#if (op "===" . "v1")~}}Ichidan verb + {{~else if (op "===" . "v5")~}}Godan verb + {{~else if (op "===" . "vk")~}}Kuru verb + {{~else if (op "===" . "vs")~}}Suru verb + {{~else if (op "===" . "vz")~}}Zuru verb + {{~else if (op "===" . "adj-i")~}}I-adjective + {{~else if (op "===" . "n")~}}Noun + {{~else~}}{{.}} + {{~/if~}} +{{/inline}} + +{{#*inline "part-of-speech"}} + {{~#scope~}} + {{~#if (op "!==" definition.type "kanji")~}} + {{~#set "first" true}}{{/set~}} + {{~#each definition.expressions~}} + {{~#each wordClasses~}} + {{~#unless (get (concat "used_" .))~}} + {{~> part-of-speech-pretty . ~}} + {{~#unless (get "first")}}, {{/unless~}} + {{~#set (concat "used_" .) true~}}{{~/set~}} + {{~#set "first" false~}}{{~/set~}} + {{~/unless~}} + {{~/each~}} + {{~/each~}} + {{~#if (get "first")~}}Unknown{{~/if~}} + {{~/if~}} + {{~/scope~}} +{{/inline}} diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index 0f390e8d..ec57a826 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -341,4 +341,35 @@ {{~/scope~}} {{/inline}} +{{#*inline "part-of-speech-pretty"}} + {{~#if (op "===" . "v1")~}}Ichidan verb + {{~else if (op "===" . "v5")~}}Godan verb + {{~else if (op "===" . "vk")~}}Kuru verb + {{~else if (op "===" . "vs")~}}Suru verb + {{~else if (op "===" . "vz")~}}Zuru verb + {{~else if (op "===" . "adj-i")~}}I-adjective + {{~else if (op "===" . "n")~}}Noun + {{~else~}}{{.}} + {{~/if~}} +{{/inline}} + +{{#*inline "part-of-speech"}} + {{~#scope~}} + {{~#if (op "!==" definition.type "kanji")~}} + {{~#set "first" true}}{{/set~}} + {{~#each definition.expressions~}} + {{~#each wordClasses~}} + {{~#unless (get (concat "used_" .))~}} + {{~> part-of-speech-pretty . ~}} + {{~#unless (get "first")}}, {{/unless~}} + {{~#set (concat "used_" .) true~}}{{~/set~}} + {{~#set "first" false~}}{{~/set~}} + {{~/unless~}} + {{~/each~}} + {{~/each~}} + {{~#if (get "first")~}}Unknown{{~/if~}} + {{~/if~}} + {{~/scope~}} +{{/inline}} + {{~> (lookup . "marker") ~}} -- cgit v1.2.3