Module: Semr::Normalizers
- Included in:
- Language
- Defined in:
- lib/semr/normalizers.rb
Instance Method Summary collapse
- #as_class ⇒ Object
- #as_fixnum ⇒ Object
- #as_list ⇒ Object
- #as_list_of_classes ⇒ Object
- #by_removing_outer_quotes ⇒ Object
- #each_item(block) ⇒ Object
- #lookup_synonyms ⇒ Object
Instance Method Details
#as_class ⇒ Object
7 8 9 |
# File 'lib/semr/normalizers.rb', line 7 def as_class proc { |value| value.classify.constantize } end |
#as_fixnum ⇒ Object
11 12 13 |
# File 'lib/semr/normalizers.rb', line 11 def as_fixnum proc { |value| value.to_i } end |
#as_list ⇒ Object
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_classes ⇒ Object
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_quotes ⇒ Object
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_synonyms ⇒ Object
23 24 25 |
# File 'lib/semr/normalizers.rb', line 23 def lookup_synonyms proc { |value| Dictionary.find_root(value) } end |