Class: Qipowl::Mappers::BowlerMapper

Inherits:
Mapper show all
Includes:
TypoLogging
Defined in:
lib/qipowl/core/mapper.rb

Direct Known Subclasses

HtmlBowlerMapper, IspruBowlerMapper

Instance Method Summary collapse

Methods included from TypoLogging

#logger, logger

Methods inherited from Mapper

#load_yaml, #load_yaml_file, #merge!, #to_hash

Constructor Details

#initialize(input = nil) ⇒ BowlerMapper

Returns a new instance of BowlerMapper.



58
59
60
61
# File 'lib/qipowl/core/mapper.rb', line 58

def initialize input = nil
  input = self.class.name.split('::').last.downcase.gsub(/bowlermapper\Z/, '') if input.nil?
  super input
end

Instance Method Details

#entitiesObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/qipowl/core/mapper.rb', line 65

def entities
  return @entities unless @entities_dirty && @hash[:entities]
  @entities = {}
  @hash[:entities].each { |key, value| # :block. :alone etc
    @entities[key] ||= {}
    value.each { |k, v|
      # Append keys
      @entities[key][k.bowl] = v.dup
      if Hash === v
        @entities[key][k.bowl].delete(:synonyms)
        # Append explicit synonyms
        v[:synonyms].each { |syn|
          syn = syn.bowl.to_sym
          (@entities[key][syn] = v.dup).delete(:synonyms)
          @entities[key][syn][:marker] = k.bowl
        } if v[:synonyms]
      end
    }
  }
  @entities_dirty = false
  @entities
end