Class: MecabNode
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- MecabNode
- Defined in:
- lib/nameko/node.rb
Overview
This class define Node struct Nameko::Mecab#parse method return it.
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key) ⇒ Object (private)
78 79 80 |
# File 'lib/nameko/node.rb', line 78 def method_missing(key) self[key] end |
Instance Method Details
#feature ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nameko/node.rb', line 27 def feature feature = self[:feature].force_encoding(Encoding.default_external).match(/ ^ (?: (?<pos>[^,]+), \*?(?<pos1>[^,]*), \*?(?<pos2>[^,]*), \*?(?<pos3>[^,]*), \*?(?<conjugation_form>[^,]*), \*?(?<conjugation>[^,]*), (?<base>[^,]*) (?: ,(?<yomi>[^,]*) ,(?<pronunciation>[^,]*) )? )? /x) do |md| md.named_captures.map{ |k, v| [k.to_sym, v] }.to_h end fill_up(feature) end |
#next ⇒ Object
50 51 52 |
# File 'lib/nameko/node.rb', line 50 def next MecabNode.new self[:next] end |
#surface ⇒ Object
54 55 56 |
# File 'lib/nameko/node.rb', line 54 def surface self[:surface][0...self[:length]].force_encoding(Encoding.default_external) end |