<commit_before>class OcrSearchController < CatalogController

  ##
  # access to the CatalogController configuration
  include Blacklight::Configurable
  include Blacklight::SearchHelper
  include CommonwealthVlrEngine::CatalogHelper

  copy_blacklight_config_from(CatalogController)

  before_filter :modify_config_for_ocr, :only => [:index]

  def index
    @doc_response, @document = fetch(params[:id])
    if params[:ocr_q]
      if !params[:ocr_q].blank?
        @image_pid_list = image_file_pids(get_image_files(params[:id]))
        ocr_search_params = {q: params[:ocr_q],
                             f: {'is_file_of_ssim' => "info:fedora/#{params[:id]}"}}
        ocr_search_params[:page] = params[:page] if params[:page]
        ocr_search_params[:sort] = params[:sort] if params[:sort]
        # for some reason, have to set :fl here, or gets scrubbed out of ocr_search_params somehow
        blacklight_config.default_solr_params[:fl] =
            "id,#{blacklight_config.page_num_field},#{termfreq_query(params[:ocr_q])}"
        (@response, @document_list) = search_results(ocr_search_params)
      else
        (@response, @document_list) = Blacklight::Solr::Response.new(nil,nil), []
      end
    else
      (@response, @document_list) = {},[]<commit_msg>OCR search should only return objects with is_image_of relationship<commit_after>class OcrSearchController < CatalogController

  ##
  # access to the CatalogController configuration
  include Blacklight::Configurable
  include Blacklight::SearchHelper
  include CommonwealthVlrEngine::CatalogHelper

  copy_blacklight_config_from(CatalogController)

  before_filter :modify_config_for_ocr, :only => [:index]

  def index
    @doc_response, @document = fetch(params[:id])
    if params[:ocr_q]
      if !params[:ocr_q].blank?
        @image_pid_list = image_file_pids(get_image_files(params[:id]))
        ocr_search_params = {q: params[:ocr_q],
                             f: {'is_image_of_ssim' => "info:fedora/#{params[:id]}"}}
        ocr_search_params[:page] = params[:page] if params[:page]
        ocr_search_params[:sort] = params[:sort] if params[:sort]
        # for some reason, have to set :fl here, or gets scrubbed out of ocr_search_params somehow
        blacklight_config.default_solr_params[:fl] =
            "id,#{blacklight_config.page_num_field},#{termfreq_query(params[:ocr_q])}"
        (@response, @document_list) = search_results(ocr_search_params)
      else
        (@response, @document_list) = Blacklight::Solr::Response.new(nil,nil), []
      end
    else
      (@response, @document_list) = {},[]
{'fraction_non_alphanumeric': 0.11995386389850057, 'fraction_numerical': 0.0, 'mean_word_length': 4.032882011605416, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6527023', 'n_tokens_mistral': 806, 'n_tokens_neox': 793, 'n_words': 152}