<commit_before>#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

require 'fileutils'
require 'optparse'

TABLE_CREATE = "table_create Geo TABLE_HASH_KEY ShortText\n"
COLUMN_CREATE = "column_create Geo distance COLUMN_SCALAR Int32\n"
LOAD = <<-EOF
load --table Geo
[
{"_key": "the record for geo_distance() result"}
]
EOF
CREATE_RESULT = "[[0,0.0,0.0],true]\n"
LOAD_RESULT = "[[0,0.0,0.0],1]\n"

SELECT = "select Geo --output_columns distance "

SELECT_PRE = "[[0,0.0,0.0],[[[1],[[\"_score\",\"Int32\"]],["
SELECT_POST = "]]]]"

class GrnTestData
  attr_accessor :csv_file
  attr_accessor :options

  attr_accessor :longitude_start_degree
  attr_accessor :latitude_start_degree
  attr_accessor :longitude_end_degree
  attr_accessor :latitude_end_degree

  attr_accessor :longitude_start
  attr_accessor :latitude_start
  attr_accessor :longitude_end
  attr_accessor :latitude_end

  attr_accessor :distance
  attr_accessor :output_filename

  def initialize(options={})
    @csv_file = options[:csv]
    @options = options
  end

  def parse_line_data(data)
    @longitude_start_degree, @latitude_start_degree,
      @longitude_end_degree, @latitude_end_degree,
      @longitude_start, @latitude_start,
      @longitude_end, @latitude_end,
      @distance, @output_filename = data.chomp.split(",")

    @longitude_start_degree = @longitude_start_degree.to_i
    @latitude_start_degree = @latitude_start_degree.to_i
    @longitude_end_degree = @longitude_end_degree.to_i
    @latitude_end_degree = @latitude_end_degree.to_i
  end

  def meridian?(lng, lat)
  end

  def equator?(lng, lat)
  end

  def east_axis?(lng, lat)
    lng >= 0 and lat == 0
  end

  def west_axis?(lng, lat)
    lng <= 0 and lat == 0
  end

  def north_axis?(lng, lat)
    lng == 0 and lat >= 0
  end

  def south_axis?(lng, lat)
    lng == 0 and lat <= 0
  end

  def quadrant_point?(longitude, latitude)
    if longitude > 0 and latitude > 0
      "1st"
    elsif longitude < 0 and latitude > 0
      "2nd"
    elsif longitude < 0 and latitude < 0
      "3rd"
    elsif longitude > 0 and latitude < 0
      "4th"
    else
      nil
    end
  end

  def east_axis_to_north_axis?
    east_axis?(@longitude_start_degree, @latitude_start_degree) and
      north_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def north_axis_to_east_axis?
    north_axis?(@longitude_start_degree, @latitude_start_degree) and
      east_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def north_axis_to_west_axis?
    north_axis?(@longitude_start_degree, @latitude_start_degree) and
      west_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def west_axis_to_north_axis?
    west_axis?(@longitude_start_degree, @latitude_start_degree) and
      north_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def west_axis_to_south_axis?
    west_axis?(@longitude_start_degree, @latitude_start_degree) and
      south_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def quadrant_point_with_axis(quadrant, longitude, latitude)
    case quadrant
    when "1st"
      if longitude >= 0 and latitude >= 0
        "1st"
      else
        nil
      end
    when "2nd"
      if longitude <= 0 and latitude >= 0
        "2nd"
      else
        nil
      end
    when "3rd"
      if longitude <= 0 and latitude <= 0
        "3rd"
      else
        nil
      end
    when "4th"
      if longitude >= 0 and latitude <= 0
        "4th"
      else
        nil
      end
    end
  end

  def south_axis_to_west_axis?
    south_axis?(@longitude_start_degree, @latitude_start_degree) and
      west_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def east_axis_to_south_axis?
    east_axis?(@longitude_start_degree, @latitude_start_degree) and
            south_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def south_axis_to_east_axis?
    south_axis?(@longitude_start_degree, @latitude_start_degree) and
      east_axis?(@longitude_end_degree, @latitude_end_degree)
  end


  def within_specified_quadrant?(quadrant)
    start_quadrant = quadrant_point_with_axis?(quadrant,
                                               @longitude_start_degree,
                                               @latitude_start_degree)
    end_quadrant = quadrant_point_with_axis?(quadrant,
                                             @longitude_end_degree,
                                             @latitude_end_degree)
    quadrant == start_quadrant and quadrant == end_quadrant
  end

  def quadrant<commit_msg>test: fix a method name formerly renamed<commit_after>#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

require 'fileutils'
require 'optparse'

TABLE_CREATE = "table_create Geo TABLE_HASH_KEY ShortText\n"
COLUMN_CREATE = "column_create Geo distance COLUMN_SCALAR Int32\n"
LOAD = <<-EOF
load --table Geo
[
{"_key": "the record for geo_distance() result"}
]
EOF
CREATE_RESULT = "[[0,0.0,0.0],true]\n"
LOAD_RESULT = "[[0,0.0,0.0],1]\n"

SELECT = "select Geo --output_columns distance "

SELECT_PRE = "[[0,0.0,0.0],[[[1],[[\"_score\",\"Int32\"]],["
SELECT_POST = "]]]]"

class GrnTestData
  attr_accessor :csv_file
  attr_accessor :options

  attr_accessor :longitude_start_degree
  attr_accessor :latitude_start_degree
  attr_accessor :longitude_end_degree
  attr_accessor :latitude_end_degree

  attr_accessor :longitude_start
  attr_accessor :latitude_start
  attr_accessor :longitude_end
  attr_accessor :latitude_end

  attr_accessor :distance
  attr_accessor :output_filename

  def initialize(options={})
    @csv_file = options[:csv]
    @options = options
  end

  def parse_line_data(data)
    @longitude_start_degree, @latitude_start_degree,
      @longitude_end_degree, @latitude_end_degree,
      @longitude_start, @latitude_start,
      @longitude_end, @latitude_end,
      @distance, @output_filename = data.chomp.split(",")

    @longitude_start_degree = @longitude_start_degree.to_i
    @latitude_start_degree = @latitude_start_degree.to_i
    @longitude_end_degree = @longitude_end_degree.to_i
    @latitude_end_degree = @latitude_end_degree.to_i
  end

  def meridian?(lng, lat)
  end

  def equator?(lng, lat)
  end

  def east_axis?(lng, lat)
    lng >= 0 and lat == 0
  end

  def west_axis?(lng, lat)
    lng <= 0 and lat == 0
  end

  def north_axis?(lng, lat)
    lng == 0 and lat >= 0
  end

  def south_axis?(lng, lat)
    lng == 0 and lat <= 0
  end

  def quadrant_point?(longitude, latitude)
    if longitude > 0 and latitude > 0
      "1st"
    elsif longitude < 0 and latitude > 0
      "2nd"
    elsif longitude < 0 and latitude < 0
      "3rd"
    elsif longitude > 0 and latitude < 0
      "4th"
    else
      nil
    end
  end

  def east_axis_to_north_axis?
    east_axis?(@longitude_start_degree, @latitude_start_degree) and
      north_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def north_axis_to_east_axis?
    north_axis?(@longitude_start_degree, @latitude_start_degree) and
      east_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def north_axis_to_west_axis?
    north_axis?(@longitude_start_degree, @latitude_start_degree) and
      west_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def west_axis_to_north_axis?
    west_axis?(@longitude_start_degree, @latitude_start_degree) and
      north_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def west_axis_to_south_axis?
    west_axis?(@longitude_start_degree, @latitude_start_degree) and
      south_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def quadrant_point_with_axis(quadrant, longitude, latitude)
    case quadrant
    when "1st"
      if longitude >= 0 and latitude >= 0
        "1st"
      else
        nil
      end
    when "2nd"
      if longitude <= 0 and latitude >= 0
        "2nd"
      else
        nil
      end
    when "3rd"
      if longitude <= 0 and latitude <= 0
        "3rd"
      else
        nil
      end
    when "4th"
      if longitude >= 0 and latitude <= 0
        "4th"
      else
        nil
      end
    end
  end

  def south_axis_to_west_axis?
    south_axis?(@longitude_start_degree, @latitude_start_degree) and
      west_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def east_axis_to_south_axis?
    east_axis?(@longitude_start_degree, @latitude_start_degree) and
            south_axis?(@longitude_end_degree, @latitude_end_degree)
  end

  def south_axis_to_east_axis?
    south_axis?(@longitude_start_degree, @latitude_start_degree) and
      east_axis?(@longitude_end_degree, @latitude_end_degree)
  end


  def within_specified_quadrant?(quadrant)
    start_quadrant = quadrant_point_with_axis(quadrant,
                                              @longitude_start_degree,
                                              @latitude_start_degree)
    end_quadrant = quadrant_point_with_axis(quadrant,
                                            @longitude_end_degree,
                                            @latitude_end_degree)
    quadrant == start_quadrant and quadrant == end_quadrant
  end

  def quadrant
{'fraction_non_alphanumeric': 0.08986404332928043, 'fraction_numerical': 0.012821929921520946, 'mean_word_length': 3.133394243947008, 'pattern_counts': {'":': 2, '<': 27, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6639955', 'n_tokens_mistral': 3250, 'n_tokens_neox': 3091, 'n_words': 635}