Class: Treat::Config::Tags

Inherits:
Object
  • Object
show all
Defined in:
lib/treat/config/tags.rb

Overview

Handles all configuration related to understanding of part of speech and phrasal tags.

Class Method Summary collapse

Class Method Details

.align_tags(tags, tag_sets) ⇒ Object

Helper methods for tag set config. Align tag tags in the tag set



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/treat/config/tags.rb', line 24

def self.align_tags(tags, tag_sets)
  wttc = {}
  tags.each_slice(2) do |desc, tags|
    category = desc.gsub(',', ' ,').
    split(' ')[0].downcase
    tag_sets.each_with_index do |tag_set, i|
      next unless tags[i]
      wttc[tags[i]] ||= {}
      wttc[tags[i]][tag_set] = category
    end
  end; return wttc
end

.configure!Object

Generate a map of word and phrase tags to their syntactic category, keyed by tag set.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/treat/config/tags.rb', line 9

def self.configure!
   super
   config = self.config[:aligned].dup
   word_tags, phrase_tags, tag_sets = 
   config[:word_tags], config[:phrase_tags]
   tag_sets = config[:tag_sets]
   config[:word_tags_to_category] = 
   align_tags(word_tags, tag_sets)
   config[:phrase_tags_to_category] =
   align_tags(phrase_tags, tag_sets)
   self.config[:aligned] = config
end