<commit_before>include Yahoo::GeoPlanet
Yahoo::GeoPlanet.app_id = ENV['YAHOO_APP_ID']

class OutletLocation
  attr_accessor :woe_id
  attr_reader :location_type, :city, :state, :country, :longitude, :latitude
  
  # Class methods
  
  def self.find_by_text(query_text)
    Place.search(query_text).flat_map do |place|
      # Ignore place types we don't know how to handle
      case place.type
      when 'Town', 'State', 'Province', 'Point of Interest', 'Country', 'District', 'Territory'
        self.new(place.woe_id, place)
      else
        []
      end
    end
  end
  
  def self.find_by_id(woe_id)
    return nil unless woe_id
    
    place = Place.new(woe_id)<commit_msg>Fixed an error case in the /locations API call.<commit_after>include Yahoo::GeoPlanet
Yahoo::GeoPlanet.app_id = ENV['YAHOO_APP_ID']

class OutletLocation
  attr_accessor :woe_id
  attr_reader :location_type, :city, :state, :country, :longitude, :latitude
  
  # Class methods
  
  def self.find_by_text(query_text)
    return [] if query_text.nil?
    Place.search(query_text).flat_map do |place|
      # Ignore place types we don't know how to handle
      case place.type
      when 'Town', 'State', 'Province', 'Point of Interest', 'Country', 'District', 'Territory'
        self.new(place.woe_id, place)
      else
        []
      end
    end
  end
  
  def self.find_by_id(woe_id)
    return nil unless woe_id
    
    place = Place.new(woe_id)
{'fraction_non_alphanumeric': 0.104675505931612, 'fraction_numerical': 0.0, 'mean_word_length': 3.242603550295858, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5975381', 'n_tokens_mistral': 520, 'n_tokens_neox': 505, 'n_words': 124}