summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.config/nushell/config.nu1
-rw-r--r--.config/nushell/japanese-helper.nu16
-rw-r--r--.gitignore1
3 files changed, 18 insertions, 0 deletions
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