<commit_before>class Entity < ActiveRecord::Base

  belongs_to :specific_entity, :polymorphic => true

  scope :item, lambda { |entity| where("specific_entity_type =? AND specific_entity_id = ?", "Item", entity.id) }
end
<commit_msg>entity scopes<commit_after>class Entity < ActiveRecord::Base

  belongs_to :specific_entity, :polymorphic => true

  scope :item, lambda { |entity| where("specific_entity_type =? AND specific_entity_id = ?", "Item", entity.id) }
  scope :villages_with_ids, lambda { |village_ids| where("specific_entity_id IN (?) AND specific_entity_type = ?", village_ids, "Village")}

  GROUP_ENTITIES = ["Village"]

  #Find entities that are connected with person involved, update with more generic, pairing up id and entity type
  def self.groups_with_person(person)
    entities = []
    village_ids = HumanNetwork.entity_types(GROUP_ENTITIES).member(person).map(&:entity_id)
    entities += self.villages_with_ids(village_ids)
  end
end

{'fraction_non_alphanumeric': 0.11470281543274244, 'fraction_numerical': 0.0, 'mean_word_length': 5.857142857142857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1028905', 'n_tokens_mistral': 313, 'n_tokens_neox': 300, 'n_words': 73}