Class: PROIEL::Converter::TNT

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

Class Method Summary collapse

Class Method Details

.process(tb, options) ⇒ Object



4
5
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
# File 'lib/proiel/cli/converters/tnt.rb', line 4

def process(tb, options)
  tb.sources.each do |source|
    puts "%% Source #{source.id}"
    puts '--'

    source.divs.each do |div|
      div.sentences.each do |sentence|
        puts "%% Sentence #{sentence.id}"
        sentence.tokens.each do |token|
          if options['pos'] or options['morphology']
            unless token.form.nil? or token.pos.nil?
              if options['morphology']
                unless token.morphology.nil?
                  puts [token.form, token.pos + token.morphology].join("\t")
                end
              else
                puts [token.form, token.pos].join("\t")
              end
            end
          else
            puts token.form
          end
        end
        puts '--'
      end
    end
  end
end