<commit_before>module Socializer
  class Audience < ActiveRecord::Base
    extend Enumerize

    enumerize :privacy_level, in: { public: 1, circles: 2, limited: 3 }, default: :public, predicates: true, scope: true

    attr_accessible :activity_id, :privacy_level

    belongs_to :activity
    belongs_to :activity_object

    # validates :activity_id, presence: true, uniqueness: { scope: :activity_object_id }
    validates :privacy_level, presence: true

    def object
      @object ||= activity_object.activitable
    end

    # Returns a [Hash] containing the value and text for the privacy level
    #
    # @example
    #   privacy_level_hash(:public)
    #
    # @param  privacy_symbol [Symbol] The symbol representing the Audience privacy_level
    #
    # @return [Hash] Using the example you will get {id: 1, name: 'Public'}
    def self.privacy_level_hash(privacy_symbol)
      privacy_symbol = privacy_symbol.downcase.to_sym
      privacy_level  = Socializer::Audience.privacy_level
      privacy        = privacy_level.find_value(privacy_symbol)<commit_msg>fix documentation<commit_after>module Socializer
  class Audience < ActiveRecord::Base
    extend Enumerize

    enumerize :privacy_level, in: { public: 1, circles: 2, limited: 3 }, default: :public, predicates: true, scope: true

    attr_accessible :activity_id, :privacy_level

    belongs_to :activity
    belongs_to :activity_object

    # validates :activity_id, presence: true, uniqueness: { scope: :activity_object_id }
    validates :privacy_level, presence: true

    def object
      @object ||= activity_object.activitable
    end

    # Returns a [Hash] containing the value and text for the privacy level
    #
    # @example
    #   privacy_level_hash(:public)
    #
    # @param  privacy_symbol [Symbol] The symbol representing the Audience privacy_level
    #
    # @return [Hash] Using the example you will get !{id: 1, name: 'Public'}
    def self.privacy_level_hash(privacy_symbol)
      privacy_symbol = privacy_symbol.downcase.to_sym
      privacy_level  = Socializer::Audience.privacy_level
      privacy        = privacy_level.find_value(privacy_symbol)
{'fraction_non_alphanumeric': 0.08143322475570032, 'fraction_numerical': 0.0037226617031177293, 'mean_word_length': 3.73568281938326, 'pattern_counts': {'":': 0, '<': 5, '<?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': '225615', 'n_tokens_mistral': 647, 'n_tokens_neox': 637, 'n_words': 176}