<commit_before>'''
Write a geojson feature collection
'''
require 'json'

class GeoJSONWriter

  attr_reader :filename

  def initialize(filename)
    @filename = filename.dup #Getting weird frozen error...
    unless @filename =~ /\.geojson$/
      @filename << '.geojson'
    end
    @open_file = File.open(@filename, 'w')
  end

  def add_options(options_hash)
    @options = options_hash
  end

  def write_header
    @open_file.write "{\"type\" : \"FeatureCollection\","
    unless @options.nil?
      @open_file.write @options.to_json
    end
    @open_file.write "\"features\" :["
  end

  def write_feature(geometry, properties)
    @open_file.write "{"
    @open_file.write "\"type\" : \"Feature\", "
    @open_file.write "\"geometry\" : #{geometry.to_json},"
    @open_file.write "\"properties\" : #{properties.to_json}"
    @open_file.write "},"
  end

  def literal_write_feature(feature)
    @open_file.write(feature)<commit_msg>Updated the outdated files again<commit_after>'''
Write a geojson feature collection
'''
require 'json'

class GeoJSONWriter

  attr_reader :filename

  def initialize(filename)
    @filename = filename.dup #Getting weird frozen error...
    unless @filename =~ /\.geojson$/
      @filename << '.geojson'
    end
    @open_file = File.open(@filename, 'w')
  end

  def add_options(options_array)
    @options = options_array
  end

  def write_header
    @open_file.write "{\"type\" : \"FeatureCollection\","
    unless @options.nil?
      @options.each do |option|
        opt_string = option.to_json.to_s
        @open_file.write opt_string[1..-2]
        @open_file.write(',')
      end
    end
    @open_file.write "\"features\" :["
  end

  def write_feature(geometry, properties)
    @open_file.write "{"
    @open_file.write "\"type\" : \"Feature\", "
    @open_file.write "\"geometry\" : #{geometry.to_json},"
    @open_file.write "\"properties\" : #{properties.to_json}"
    @open_file.write "},"
  end

  def literal_write_feature(feature)
    @open_file.write(feature)
{'fraction_non_alphanumeric': 0.14794656110836218, 'fraction_numerical': 0.0009896091044037606, 'mean_word_length': 3.221294363256785, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2642484', 'n_tokens_mistral': 678, 'n_tokens_neox': 653, 'n_words': 142}