<commit_before>require 'jbundler'
require 'json'
require 'sinatra'
require 'sinatra/json'

java_import com.bericotech.clavin.GeoParserFactory

parser = GeoParserFactory.get_default "./tmp/index"

post '/search.json' do

  params.merge! JSON.parse(request.body.read)

  resolved_locations = parser.parse(params[:q])

  json resolved_locations.map{|location|
    { location_name: location.location.text,
      matched_name:  location.matchedName,
      confidence:    location.confidence,
      fuzzy:         location.fuzzy,<commit_msg>capitalize search words<commit_after>require 'jbundler'
require 'json'
require 'sinatra'
require 'sinatra/json'

java_import com.bericotech.clavin.GeoParserFactory

parser = GeoParserFactory.get_default "./tmp/index"

post '/search.json' do

  params.merge! JSON.parse(request.body.read)

  # Capitalize all terms so that they may be identified as places.
  query = params[:q].split.map(&:capitalize).join(" ")

  resolved_locations = parser.parse query

  json resolved_locations.map{|location|
    { location_name: location.location.text,
      matched_name:  location.matchedName,
      confidence:    location.confidence,
      fuzzy:         location.fuzzy,
{'fraction_non_alphanumeric': 0.10693400167084377, 'fraction_numerical': 0.0, 'mean_word_length': 4.277533039647577, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1393125', 'n_tokens_mistral': 386, 'n_tokens_neox': 358, 'n_words': 75}