<commit_before>module Xapit
  # Use "include Xapit::Membership" on a class to allow xapian searching on it. This is automatically included
  # in ActiveRecord::Base so you do not need to do anything there.
  module Membership
    def self.included(base)
      base.extend ClassMethods
      base.send(:attr_accessor, :xapit_relevance) # is there a better way to do this?
    end
    
    module ClassMethods
      # Used to perform a search on a model.
      #   
      #   # perform a simple full text search
      #   @articles = Article.search("phone")
      #   
      #   # add pagination if you're using will_paginate
      #   @articles = Article.search("phone", :per_page => 10, :page => params[:page])
      #   
      #   # search based on indexed fields
      #   @articles = Article.search("phone", :conditions => { :category_id => params[:category_id] })
      #   
      #   # manually sort based on any number of indexed fields, sort defaults to most relevant
      #   @articles = Article.search("phone", :order => [:category_id, :id], :descending => true)
      #
      #   # basic boolean matching is supported
      #   @articles = Article.search("phone or fax not email")
      #
      def search(*args)
        Collection.new(self, *args)
      end
      
      # Simply call "xapit" on a class and pass a block to define the indexed attributes.
      # 
      #   class Article < ActiveRecord::Base
      #     xapit do |index|
      #       index.text :name, :content
      #       index.field :category_id
      #       index.facet :author_name, "Author"
      #       index.sortable :id, :category_id
      #     end
      #   end
      # 
      # First we index "name" and "content" attributes for full text searching. The "category_id" field is indexed for :conditions searching. The "author_name" is indexed as a facet with "Author" being the display name of the facet. See the facets section below for details. Finally the "id" and "category_id" attributes are indexed as sortable attributes so they can be included in the :order option in a search.
      # 
      # Because the indexing happens in Ruby these attributes do no have to be database columns. They can be simple Ruby methods. For example, the "author_name" attribute mentioned above can be defined like this.
      # 
      #   def author_name
      #     author.name
      #   end<commit_msg>adding documentation about no query string argument required<commit_after>module Xapit
  # Use "include Xapit::Membership" on a class to allow xapian searching on it. This is automatically included
  # in ActiveRecord::Base so you do not need to do anything there.
  module Membership
    def self.included(base)
      base.extend ClassMethods
      base.send(:attr_accessor, :xapit_relevance) # is there a better way to do this?
    end
    
    module ClassMethods
      # Used to perform a search on a model.
      #   
      #   # perform a simple full text search
      #   @articles = Article.search("phone")
      #   
      #   # add pagination if you're using will_paginate
      #   @articles = Article.search("phone", :per_page => 10, :page => params[:page])
      #   
      #   # search based on indexed fields
      #   @articles = Article.search("phone", :conditions => { :category_id => params[:category_id] })
      #   
      #   # manually sort based on any number of indexed fields, sort defaults to most relevant
      #   @articles = Article.search("phone", :order => [:category_id, :id], :descending => true)
      #
      #   # basic boolean matching is supported
      #   @articles = Article.search("phone or fax not email")
      #
      #   # no need to specify first query string when searching all records
      #   @articles = Article.search(:conditions => { :category_id => params[:category_id] })
      #
      def search(*args)
        Collection.new(self, *args)
      end
      
      # Simply call "xapit" on a class and pass a block to define the indexed attributes.
      # 
      #   class Article < ActiveRecord::Base
      #     xapit do |index|
      #       index.text :name, :content
      #       index.field :category_id
      #       index.facet :author_name, "Author"
      #       index.sortable :id, :category_id
      #     end
      #   end
      # 
      # First we index "name" and "content" attributes for full text searching. The "category_id" field is indexed for :conditions searching. The "author_name" is indexed as a facet with "Author" being the display name of the facet. See the facets section below for details. Finally the "id" and "category_id" attributes are indexed as sortable attributes so they can be included in the :order option in a search.
      # 
      # Because the indexing happens in Ruby these attributes do no have to be database columns. They can be simple Ruby methods. For example, the "author_name" attribute mentioned above can be defined like this.
      # 
      #   def author_name
      #     author.name
      #   end
{'fraction_non_alphanumeric': 0.08326661329063251, 'fraction_numerical': 0.0008006405124099279, 'mean_word_length': 2.467730742539903, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '7355814', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1334, 'n_words': 539}