Module: Semr::Normalizers

Included in:
Language
Defined in:
lib/semr/normalizers.rb

Instance Method Summary collapse

Instance Method Details

#as_classObject



7
8
9
# File 'lib/semr/normalizers.rb', line 7

def as_class
  proc { |value| value.classify.constantize }
end

#as_fixnumObject



11
12
13
# File 'lib/semr/normalizers.rb', line 11

def as_fixnum
  proc { |value| value.to_i }
end

#as_listObject



15
16
17
# File 'lib/semr/normalizers.rb', line 15

def as_list
  proc { |value| value.split(/,|and/).map{|item| item.strip} }
end

#as_list_of_classesObject



19
20
21
# File 'lib/semr/normalizers.rb', line 19

def as_list_of_classes
  proc { |value| value.split(/,|and/).map{|item| item.strip.classify.constantize } }
end

#by_removing_outer_quotesObject



3
4
5
# File 'lib/semr/normalizers.rb', line 3

def by_removing_outer_quotes
  proc { |value| value.gsub("'", "") }
end

#each_item(block) ⇒ Object



27
28
29
# File 'lib/semr/normalizers.rb', line 27

def each_item(block)
  proc { |value| value.map{|item| block.call(item) } }
end

#lookup_synonymsObject



23
24
25
# File 'lib/semr/normalizers.rb', line 23

def lookup_synonyms
  proc { |value| Dictionary.find_root(value) }
end