class WWWJDic::Parsers::Key
This class is an implementation of the Parsable duck type that checks the display type. The only needed parameter is the word to translate.
k is the key type:
-
for dictionary lookups
-
for English keys use E, or P to get just “common words”, Q to
-
get an “exact match” and R to get both;
* for Japanese keys use J (this is mandatory for romaji keys),
P to get just “common words” (doesn't work with romaji), K for keys starting with kanji (first position), and L for kanji keys in any position.
-
for kanji lookups, use M followed by the KANJIDIC letter codes
(B, U, V, N, etc.) or J if a reading or kanji is being provided. An optional stroke-count or stroke-count range can be included by placing it between “=” characters;
-
for text glossing use G, or H to turn on the “no repeated
translations“ option.
-
for multi-radical kanji lookups use J for jouyou kanji-only, H
to include JIS X 0212 kanji, and X for anything else. An optional stroke-count or stroke-count range can be included by placing it between “=” characters.
-
for example sentence lookups with indexed words use E for EUC,
ISO-2022-JP or UCS, S for Shift_JIS and U for UTF-8, followed by “lookupword=n=kana=”. The kana is optional and is there to disambiguate between different headwords. For “n”, 1 => random selection of 10, anything else => display up to 100 sentences starting at n.
-
for example sentence lookups using a regular expression, use E
for EUC, ISO-2022-JP or UCS, S for Shift_JIS and U for UTF-8, followed by the search string. Up to 99 example sentences may be displayed.
- Author
- Copyright
-
© 2014-2021 Marco Bresciani
- License
-
GNU General Public License version 3
Public Instance Methods
The parsable duck type interface to every parser usage.
# File lib/wwwjdic/parsers/key.rb 71 def parse(value = :english) 72 raise ArgumentError, I18n.t('error.nil') if value.nil? 73 raise ArgumentError, I18n.t('error.param', value: value) unless value.is_a? Symbol 74 75 raiser_array('error.param', value, KEYS.keys) 76 77 value 78 end