Class Jmdict::ImportKradReader
In: lib/jmdict/import_krad_reader.rb
Parent: Jmdict::ImportReader

Methods

is_comment?   new   read  

Constants

CHARACTER_RADICAL_DELIMIT = ':'
RADICAL_RADICAL_DELIMIT = ' '

Public Class methods

[Source]

    # File lib/jmdict/import_krad_reader.rb, line 6
 6:   def initialize(filename, version, maximum_parsed = nil)
 7:     super(filename, version, maximum_parsed)
 8: 
 9:     @_language_family                             = LanguageCharacterFamily.find_by_language_id_and_family(@japanese_language.id, 'kanji')
10:     @_skip_entry                                  = false
11:     @_current_kradicals                           = Array.new
12:   end

Public Instance methods

[Source]

    # File lib/jmdict/import_krad_reader.rb, line 34
34:   def is_comment?(line)
35:     line.match('^#') or line.match('^#')
36:   end

[Source]

    # File lib/jmdict/import_krad_reader.rb, line 14
14:   def read(line)
15:     @_skip_entry = true
16:     @line = line.strip.gsub(/\n/,'')
17:     return unless @line
18:     @_skip_entry = false
19:     parts = @line.split(CHARACTER_RADICAL_DELIMIT)
20:     raise "This does not conform to [character : radicals] format" unless 2 == parts.size
21:     character  = Character.find_or_create_by_character(parts[0].strip)
22:     update_if_new(character)
23:     radicals   = parts[1].split(RADICAL_RADICAL_DELIMIT).map{ |radical| Character.find_or_create_by_character(radical.strip) }
24:     for radical in radicals
25:       update_if_new(radical)
26:       character_radical = CharacterRadical.new
27:       character_radical.character = character
28:       character_radical.radical = radical
29:       @_current_kradicals << character_radical
30:     end
31:     finalize()
32:   end

[Validate]