<commit_before>require 'csv-mapper'
require 'fuzzystringmatch'

class SicController < ApplicationController
  def index
    results = CsvMapper.import(Rails.root + 'app/assets/csv/zoning_and_sic_codes.csv') do
      start_at_row 1
      [industry, subtype, code, industry_subtype, recheck, sic_name, sic_code, alternate_code]
    end
    query = params['q']
    query_distances = Array.new(results.length)

    jarow = FuzzyStringMatch::JaroWinkler.create( :native )

    results.each_with_index { |result, index  |
      query_distances[index] = jarow.getDistance(query, result.industry_subtype)
    }

    @response = results[query_distances.index(query_distances.max)]
<commit_msg>probably better to put subtype first<commit_after>require 'csv-mapper'
require 'fuzzystringmatch'

class SicController < ApplicationController
  def index
    results = CsvMapper.import(Rails.root + 'app/assets/csv/zoning_and_sic_codes.csv') do
      start_at_row 1
      [industry, subtype, code, industry_subtype, recheck, sic_name, sic_code, alternate_code]
    end
    query = params['q']
    query_distances = Array.new(results.length)

    jarow = FuzzyStringMatch::JaroWinkler.create( :native )

    results.each_with_index { |result, index  |
      query_distances[index] = jarow.getDistance(query, result.subtype + result.industry)
    }

    @response = results[query_distances.index(query_distances.max)]

{'fraction_non_alphanumeric': 0.1, 'fraction_numerical': 0.0014285714285714286, 'mean_word_length': 4.4941176470588236, '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': '1665149', 'n_tokens_mistral': 472, 'n_tokens_neox': 455, 'n_words': 84}