summaryrefslogtreecommitdiff
path: root/.config/nushell/japanese-helper.nu
diff options
context:
space:
mode:
Diffstat (limited to '.config/nushell/japanese-helper.nu')
-rw-r--r--.config/nushell/japanese-helper.nu16
1 files changed, 16 insertions, 0 deletions
diff --git a/.config/nushell/japanese-helper.nu b/.config/nushell/japanese-helper.nu
new file mode 100644
index 0000000..6ba20b7
--- /dev/null
+++ b/.config/nushell/japanese-helper.nu
@@ -0,0 +1,16 @@
+export def "vocabulary get-id" [
+ search_term: string # search term that must exactly match either orth or hiragana reading
+] {
+ return (open $env.WADOKU_DUMP_PATH --raw
+ | rg "http://www.wadoku.de/xml/entry" --passthru --replace ""
+ | query xml $"//entry[form[/reading/hira='($search_term)' or orth='($search_term)']]/@id"
+ | get string_value)
+}
+
+export def "vocabulary show-by-id" [
+ id: string # wadoku XML entry id
+] {
+ open $env.WADOKU_DUMP_PATH --raw |
+ | rg "http://www.wadoku.de/xml/entry" --passthru --replace ""
+ | query xml $"//entry[@id=($id)]//node\(\)[self::sense or self::accent or self::orth or self::hira]" --output-string-value --output-names
+}