From b6e9a54f81de6254f85e7559ddf0256eb048fe5c Mon Sep 17 00:00:00 2001 From: WriterV2 Date: Mon, 13 Apr 2026 17:49:27 +0200 Subject: Nushell: Add japanese-helper vocab WIP --- .config/nushell/config.nu | 1 + .config/nushell/japanese-helper.nu | 16 ++++++++++++++++ .gitignore | 1 + 3 files changed, 18 insertions(+) create mode 100644 .config/nushell/japanese-helper.nu diff --git a/.config/nushell/config.nu b/.config/nushell/config.nu index d94dcda..1fa9a1d 100644 --- a/.config/nushell/config.nu +++ b/.config/nushell/config.nu @@ -886,3 +886,4 @@ use phone.nu use screen.nu use wishlist.nu use reading-order.nu +use japanese-helper.nu 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 +} diff --git a/.gitignore b/.gitignore index 2ba566e..e861893 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ !.config/nushell/screen.nu !.config/nushell/wishlist.nu !.config/nushell/youtube.nu +!.config/nushell/japanese-helper.nu !.config/nvim !.config/nvim/** !.config/polybar -- cgit v1.2.3