<commit_before>module MongoMapper
  module Plugins
    autoload :Clortho, 'clortho'
    
    module Clortho
      extend ActiveSupport::Concern
      
      included do
        class_inheritable_accessor  :searchable_with_options
        write_inheritable_attribute :searchable_with_options, []
        set_callback :create, :before, :inject_default_keywords
        extend ClassMethods
      end
      
      module ExclusionConstants
        # Helper verbs, sometimes referred to as "forms of the verb (to) 'be'", usually offer no added meaning
        VERBS       = [:have, :has, :had, :do, :does, :did, :be, :am, :is, :are, :was, :were, :having, 
                       :been, :can, :could, :shall, :should, :will, :would, :may, :might, :must, :being]
        # Article adjectives are normally fluff and offer no additional context or meaning
        ADJECTIVES  = [:a, :an, :the]
      end
      
      module ClassMethods
        
        def searchable(*args)
          options = args.extract_options!
          
          args.each do |arg|
            key :"#{arg}_keywords", String, default: ""
            key :"#{arg}_keywords_array", Array, default: []
            
            searchable_with_options << [arg.to_sym, options]
            
            class_eval <<-CODE
              class << self
                def search_#{arg}_keywords_for(keyword)
                  self.all.select{ |record| record[:'#{arg}_keywords_array'].include?(keyword) }
                end
              end
            CODE
          end
        end
        
      end
      
      module InstanceMethods
        <commit_msg>Now handling inclusive search for multiple keywords; returns array of unique documents that contain the keywords.<commit_after>module MongoMapper
  module Plugins
    autoload :Clortho, 'clortho'
    
    module Clortho
      extend ActiveSupport::Concern
      
      included do
        class_inheritable_accessor  :searchable_with_options
        write_inheritable_attribute :searchable_with_options, []
        set_callback :create, :before, :inject_default_keywords
        extend ClassMethods
      end
      
      module ExclusionConstants
        # Helper verbs, sometimes referred to as "forms of the verb (to) 'be'", usually offer no added meaning
        VERBS       = [:have, :has, :had, :do, :does, :did, :be, :am, :is, :are, :was, :were, :having, 
                       :been, :can, :could, :shall, :should, :will, :would, :may, :might, :must, :being]
        # Article adjectives are normally fluff and offer no additional context or meaning
        ADJECTIVES  = [:a, :an, :the]
      end
      
      module ClassMethods
        
        def searchable(*args)
          options = args.extract_options!
          
          args.each do |arg|
            key :"#{arg}_keywords", String, default: ""
            key :"#{arg}_keywords_array", Array, default: []
            
            searchable_with_options << [arg.to_sym, options]
            
            class_eval <<-CODE
              class << self
                def search_#{arg}_keywords_for(*keywords)
                  records = []
                  keywords.each do |word|
                    records << self.all.select{ |record| record[:'#{arg}_keywords_array'].include?(word) }
                  end
                  records.flatten.uniq
                end
              end
            CODE
          end
        end
        
      end
      
      module InstanceMethods
        
{'fraction_non_alphanumeric': 0.09088302752293578, 'fraction_numerical': 0.0, 'mean_word_length': 1.786741214057508, 'pattern_counts': {'":': 0, '<': 17, '<?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': '1301204', 'n_tokens_mistral': 968, 'n_tokens_neox': 940, 'n_words': 266}