Class: PROIEL::Converter::Lexc

Inherits:
Object
  • Object
show all
Defined in:
lib/proiel/cli/converters/lexc.rb

Overview

This converts part of speech and morphology to a lexc file.

Class Method Summary collapse

Class Method Details

.process(tb, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/proiel/cli/converters/lexc.rb', line 6

def process(tb, options)
  lexicon = {}

  tb.sources.each do |source|
    source.divs.each do |div|
      div.sentences.each do |sentence|
        sentence.tokens.each do |token|
          unless token.is_empty?
            lexicon[token.form] ||= []
            if options['morphology']
              lexicon[token.form] << [token.lemma, [token.part_of_speech, token.morphology].join].join(',')
            else
              lexicon[token.form] << [token.lemma, token.part_of_speech].join(',')
            end
          end
        end
      end
    end
  end

  puts "LEXICON Root"
  lexicon.sort.each do |form, tags|
    tags.sort.uniq.each do |tag|
      puts "  %s:%s #;" % [tag, form]
    end
  end
end