<commit_before>class Me::SearchController < Me::BaseController

  def index
    if request.post?
      path = build_filter_path(params[:search])
      redirect_to me_url(:action => 'search') + path   
    else
      @pages = Page.find_by_path(params[:path], options_for_me(:method => :sphinx, :page => params[:page]))
      
      # if there was a text string in the search, generate extracts for the results      
      if parsed_path.keyword? 'text'
        begin
        config = ThinkingSphinx::Configuration.new
        client = Riddle::Client.new config.address, config.port
        
        results = client.excerpts(
            :docs             => @pages.collect {|page| page.page_index.body},
            :words            => parsed_path.search_text,
            :index            => "page_index_core",
            :before_match     => "<b>",<commit_msg>make excerpts generation more robust<commit_after>class Me::SearchController < Me::BaseController

  def index
    if request.post?
      path = build_filter_path(params[:search])
      redirect_to me_url(:action => 'search') + path   
    else
      @pages = Page.find_by_path(params[:path], options_for_me(:method => :sphinx, :page => params[:page]))
      
      # if there was a text string in the search, generate extracts for the results      
      if parsed_path.keyword? 'text'
        begin
        config = ThinkingSphinx::Configuration.new
        client = Riddle::Client.new config.address, config.port
        
        results = client.excerpts(
            :docs             => @pages.collect {|page| page.page_index ? page.page_index.body : ""},
            :words            => parsed_path.search_text,
            :index            => "page_index_core",
            :before_match     => "<b>",
{'fraction_non_alphanumeric': 0.11204954954954954, 'fraction_numerical': 0.0, 'mean_word_length': 2.2785977859778597, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '1353345', 'n_tokens_mistral': 495, 'n_tokens_neox': 487, 'n_words': 116}