Class: Iev::TermAttrsParser
- Inherits:
-
Object
- Object
- Iev::TermAttrsParser
- Defined in:
- lib/iev/term_attrs_parser.rb
Overview
Parses information from the spreadsheet’s TERMATTRIBUTE column and alike.
Constant Summary collapse
- PARTS_OF_SPEECH =
{ "adj" => "adj", "noun" => "noun", "verb" => "verb", "名詞" => "noun", "動詞" => "verb", "形容詞" => "adj", "형용사" => "adj", "Adjektiv" => "adj", }.freeze
- PREFIX_KEYWORDS =
%w[ Präfix prefix préfixe 接尾語 접두사 przedrostek prefixo 词头 ].freeze
Instance Attribute Summary collapse
-
#gender ⇒ Object
readonly
Returns the value of attribute gender.
-
#geographical_area ⇒ Object
readonly
Returns the value of attribute geographical_area.
-
#part_of_speech ⇒ Object
readonly
Returns the value of attribute part_of_speech.
-
#plurality ⇒ Object
readonly
Returns the value of attribute plurality.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#raw_str ⇒ Object
readonly
Returns the value of attribute raw_str.
-
#src_str ⇒ Object
readonly
Returns the value of attribute src_str.
-
#usage_info ⇒ Object
readonly
Returns the value of attribute usage_info.
Instance Method Summary collapse
-
#initialize(attr_str) ⇒ TermAttrsParser
constructor
A new instance of TermAttrsParser.
- #inspect ⇒ Object
-
#to_grammar_info ⇒ Object
Constructs a Glossarist::Designation::GrammarInfo from the parsed gender, plurality, and part_of_speech attributes.
Constructor Details
#initialize(attr_str) ⇒ TermAttrsParser
Returns a new instance of TermAttrsParser.
36 37 38 39 40 |
# File 'lib/iev/term_attrs_parser.rb', line 36 def initialize(attr_str) @raw_str = attr_str.dup.freeze @src_str = decode_attrs_string(raw_str).freeze parse end |
Instance Attribute Details
#gender ⇒ Object (readonly)
Returns the value of attribute gender.
18 19 20 |
# File 'lib/iev/term_attrs_parser.rb', line 18 def gender @gender end |
#geographical_area ⇒ Object (readonly)
Returns the value of attribute geographical_area.
18 19 20 |
# File 'lib/iev/term_attrs_parser.rb', line 18 def geographical_area @geographical_area end |
#part_of_speech ⇒ Object (readonly)
Returns the value of attribute part_of_speech.
18 19 20 |
# File 'lib/iev/term_attrs_parser.rb', line 18 def part_of_speech @part_of_speech end |
#plurality ⇒ Object (readonly)
Returns the value of attribute plurality.
18 19 20 |
# File 'lib/iev/term_attrs_parser.rb', line 18 def plurality @plurality end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
18 19 20 |
# File 'lib/iev/term_attrs_parser.rb', line 18 def prefix @prefix end |
#raw_str ⇒ Object (readonly)
Returns the value of attribute raw_str.
18 19 20 |
# File 'lib/iev/term_attrs_parser.rb', line 18 def raw_str @raw_str end |
#src_str ⇒ Object (readonly)
Returns the value of attribute src_str.
18 19 20 |
# File 'lib/iev/term_attrs_parser.rb', line 18 def src_str @src_str end |
#usage_info ⇒ Object (readonly)
Returns the value of attribute usage_info.
18 19 20 |
# File 'lib/iev/term_attrs_parser.rb', line 18 def usage_info @usage_info end |
Instance Method Details
#inspect ⇒ Object
42 43 44 |
# File 'lib/iev/term_attrs_parser.rb', line 42 def inspect "<ATTRIBUTES: #{src_str}>".freeze end |
#to_grammar_info ⇒ Object
Constructs a Glossarist::Designation::GrammarInfo from the parsed gender, plurality, and part_of_speech attributes. Returns nil if none of these attributes were parsed.
49 50 51 52 53 54 55 56 57 |
# File 'lib/iev/term_attrs_parser.rb', line 49 def to_grammar_info return nil unless gender || plurality || part_of_speech Glossarist::Designation::GrammarInfo.new( gender: gender ? [gender] : nil, number: plurality ? [plurality] : nil, part_of_speech: part_of_speech, ) end |