Module: Daidai::Tables
- Defined in:
- lib/daidai/tables.rb
Overview
Loads and memoizes the JMdictDB conjugation tables vendored under ‘resources/`. The files are tab-separated and copied verbatim from jconj (Stuart McGraw / EDRDG) — see NOTICE. Keep them in sync with upstream via `rake daidai:sync`.
Defined Under Namespace
Classes: Okurigana
Constant Summary collapse
- DIR =
File.("resources", __dir__)
Class Method Summary collapse
-
.conj ⇒ Object
conjugation id (Integer) => human name (“Past (~ta)”, …).
-
.conjo ⇒ Object
- pos_id, conj_id, negative?, polite?, onum
-
> Okurigana.
-
.pos_ids ⇒ Object
JMdict POS keyword (“v5k”, “adj-i”, …) => conjo pos id (Integer).
- .reload! ⇒ Object
Class Method Details
.conj ⇒ Object
conjugation id (Integer) => human name (“Past (~ta)”, …)
18 19 20 |
# File 'lib/daidai/tables.rb', line 18 def conj @conj ||= read("conj.csv").to_h { |r| [ r["id"].to_i, r["name"] ] } end |
.conjo ⇒ Object
- pos_id, conj_id, negative?, polite?, onum
-
> Okurigana
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/daidai/tables.rb', line 23 def conjo @conjo ||= read("conjo.csv").each_with_object({}) do |r, table| key = [ r["pos"].to_i, r["conj"].to_i, r["neg"] == "t", r["fml"] == "t", r["onum"].to_i ] table[key] = Okurigana.new( stem: r["stem"].to_i, okuri: r["okuri"].to_s, euphr: presence(r["euphr"]), euphk: presence(r["euphk"]) ) end end |
.pos_ids ⇒ Object
JMdict POS keyword (“v5k”, “adj-i”, …) => conjo pos id (Integer)
36 37 38 |
# File 'lib/daidai/tables.rb', line 36 def pos_ids @pos_ids ||= read("kwpos.csv").to_h { |r| [ r["kw"], r["id"].to_i ] } end |
.reload! ⇒ Object
40 41 42 |
# File 'lib/daidai/tables.rb', line 40 def reload! @conj = @conjo = @pos_ids = nil end |