Class: Myasorubka::AOT::Gramtab
- Inherits:
-
Object
- Object
- Myasorubka::AOT::Gramtab
- Defined in:
- lib/myasorubka/aot/gramtab.rb
Overview
Tab file contains all possible full morphological patterns for the words.
One line in a Tab file looks like as follows:
<ancode> <useless_number> <pos> <grammemes>
An ancode is an ID, which consists of two letters and which uniquely identifies a morphological pattern. A morphological pattern consists of:
<pos> and <grammemes>
A MRD file refers to a Tab file, which is language-dependent.
Instance Attribute Summary collapse
-
#ancodes ⇒ Object
readonly
Returns the value of attribute ancodes.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
Instance Method Summary collapse
-
#initialize(filename, ee = nil, ie = Encoding.default_external) ⇒ Gramtab
constructor
:nodoc:.
-
#inspect ⇒ Object
:nodoc:.
Constructor Details
#initialize(filename, ee = nil, ie = Encoding.default_external) ⇒ Gramtab
:nodoc:
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/myasorubka/aot/gramtab.rb', line 22 def initialize(filename, ee = nil, ie = Encoding.default_external) @filename, @ancodes, @language, id = filename, {}, language, -1 encoding = { internal_encoding: ie, external_encoding: ee } File.readlines(filename, $/, encoding).each do |line, i| next if line.empty? or line.start_with?('//') ancode, _, pos, grammemes = line.split ancodes[ancode] = { id: id += 1, pos: pos, grammemes: grammemes || '' } end end |
Instance Attribute Details
#ancodes ⇒ Object (readonly)
Returns the value of attribute ancodes.
19 20 21 |
# File 'lib/myasorubka/aot/gramtab.rb', line 19 def ancodes @ancodes end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
19 20 21 |
# File 'lib/myasorubka/aot/gramtab.rb', line 19 def filename @filename end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
19 20 21 |
# File 'lib/myasorubka/aot/gramtab.rb', line 19 def language @language end |
Instance Method Details
#inspect ⇒ Object
:nodoc:
34 35 36 37 |
# File 'lib/myasorubka/aot/gramtab.rb', line 34 def inspect sprintf('#<%s filename=%s language=%s>', self.class.name, filename.inspect, language.inspect) end |