<commit_before>module Seek
  module ContentTypeDetection

    include Seek::MimeTypes

    MAX_EXTRACTABLE_SPREADSHEET_SIZE=(Seek::Config.max_extractable_spreadsheet_size || 10).to_i*1024*1024
    MAX_SIMULATABLE_SIZE=5*1024*1024
    PDF_CONVERTABLE_FORMAT = %w[doc docx ppt pptx odt odp rtf txt ]#xls xlsx]
    PDF_VIEWABLE_FORMAT = PDF_CONVERTABLE_FORMAT - %w[xls xlsx]
    IMAGE_VIEWABLE_FORMAT = %w[gif jpeg png jpg bmp svg]

    def is_excel? blob=self
      is_xls?(blob) || is_xlsx?(blob)
    end

    def is_extractable_spreadsheet? blob=self
      within_size_limit(blob) && is_excel?(blob)
    end

    def is_in_simulatable_size_limit? blob=self
      !blob.filesize.nil? && blob.filesize < MAX_SIMULATABLE_SIZE
    end

    def is_xlsx? blob=self
      mime_extensions(blob.content_type).include?("xlsx")
    end

    def is_xls? blob=self
      mime_extensions(blob.content_type).include?("xls")
    end

    def is_jws_dat? blob=self
      check_content blob,"begin name",25000<commit_msg>search_matched: spreadsheet convertible to pdf for search<commit_after>module Seek
  module ContentTypeDetection

    include Seek::MimeTypes

    MAX_EXTRACTABLE_SPREADSHEET_SIZE=(Seek::Config.max_extractable_spreadsheet_size || 10).to_i*1024*1024
    MAX_SIMULATABLE_SIZE=5*1024*1024
    PDF_CONVERTABLE_FORMAT = %w[doc docx ppt pptx odt odp rtf txt xls xlsx]
    PDF_VIEWABLE_FORMAT = PDF_CONVERTABLE_FORMAT - %w[xls xlsx]
    IMAGE_VIEWABLE_FORMAT = %w[gif jpeg png jpg bmp svg]

    def is_excel? blob=self
      is_xls?(blob) || is_xlsx?(blob)
    end

    def is_extractable_spreadsheet? blob=self
      within_size_limit(blob) && is_excel?(blob)
    end

    def is_in_simulatable_size_limit? blob=self
      !blob.filesize.nil? && blob.filesize < MAX_SIMULATABLE_SIZE
    end

    def is_xlsx? blob=self
      mime_extensions(blob.content_type).include?("xlsx")
    end

    def is_xls? blob=self
      mime_extensions(blob.content_type).include?("xls")
    end

    def is_jws_dat? blob=self
      check_content blob,"begin name",25000
{'fraction_non_alphanumeric': 0.08837890625, 'fraction_numerical': 0.0234375, 'mean_word_length': 4.084367245657568, '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': '1192416', 'n_tokens_mistral': 816, 'n_tokens_neox': 758, 'n_words': 137}