module Akiva::Brain::Helpers

Constants

ComparisonAdjectivesToProperties

Public Class Methods

cleanup_articles(string) click to toggle source
# File lib/akiva/core_brain/helpers/misc.rb, line 23
def self.cleanup_articles(string)
  string.gsub(/\A(a|an|the) /i, "")
end
degroup_multiple_values(string) click to toggle source
# File lib/akiva/core_brain/helpers/misc.rb, line 5
def self.degroup_multiple_values(string)
  # NOTE: we probably should check the dictionary here to improve the values detections,
  # and limit the number of requests made.
  values = []

  string.split(" && ").each do |sub0|
    sub0.split(",").each do |sub1|
      sub1.split(" and ").each do |sub2|
        val = sub2.strip
        val.gsub!(/\A(a|an|the) /i, "")
        values << val
      end
    end
  end

  values.uniq
end