<commit_before>class LangaugeFile

  def executeStage(message)
    puts message
    yield
  end

  def generate_language_file(language,duplicate)
    filename = File.join("lang", "#{language}.rb");


    stringMap = {}
    executeStage "Loading last language file #{filename}" do
      File.read(filename).scan(/["](.*?)["],(.*)/u).each do |pp|
        stringMap[pp[0]] = pp[1]
      end
    end

    stringAll = []
    executeStage "Generating #{filename}" do
      rc  = ""
      rc += "Localization.define(\"#{language}\") do |l|"
      Dir.glob("**/*.{erb,rhtml,rb}").sort.collect do |ff|
        strings   = File.read(ff).scan(/_\([ ]*["](.*?)["]/)
        strings  += File.read(ff).scan(/_\([ ]*['](.*?)[']/)
        if strings.length > 0
          strings.uniq!
          stringsRemove = strings
          strings -= stringAll
          stringAll += stringsRemove
          stringAll.uniq!
          if strings.length > 0
            rc += "\n\n  # #{ff}"
            strings.each do |ss|
              key = ss[0]
              if ( duplicate )
                rc += "\n  l.store \"#{key}\", \"#{key}\""
              else
                if stringMap.has_key?(key)
                  rc += "\n  l.store \"#{key}\",#{stringMap[key]}"
                  stringMap.delete(key)
                else
                  rc += "\n  l.store \"#{key}\", \"\""
                end
              end
            end
          end
        end
      end
      if stringMap.size > 0
        rc += "\n\n  # Obsolete translations"
        stringMap.keys.sort.each do |key|
          rc += "\n  l.store \"#{key}\",#{stringMap[key]}"
        end
      end
      rc += "\nend"
      ff = File.new(filename,"w")
      ff.write(rc)
      ff.close()
    end
  end
end

class Tool
  def initialize
    @language  = 'en_US'
    @duplicate = true
<commit_msg>Add newline at end of (re)generated language file.<commit_after>class LangaugeFile

  def executeStage(message)
    puts message
    yield
  end

  def generate_language_file(language,duplicate)
    filename = File.join("lang", "#{language}.rb");


    stringMap = {}
    executeStage "Loading last language file #{filename}" do
      File.read(filename).scan(/["](.*?)["],(.*)/u).each do |pp|
        stringMap[pp[0]] = pp[1]
      end
    end

    stringAll = []
    executeStage "Generating #{filename}" do
      rc  = ""
      rc += "Localization.define(\"#{language}\") do |l|"
      Dir.glob("**/*.{erb,rhtml,rb}").sort.collect do |ff|
        strings   = File.read(ff).scan(/_\([ ]*["](.*?)["]/)
        strings  += File.read(ff).scan(/_\([ ]*['](.*?)[']/)
        if strings.length > 0
          strings.uniq!
          stringsRemove = strings
          strings -= stringAll
          stringAll += stringsRemove
          stringAll.uniq!
          if strings.length > 0
            rc += "\n\n  # #{ff}"
            strings.each do |ss|
              key = ss[0]
              if ( duplicate )
                rc += "\n  l.store \"#{key}\", \"#{key}\""
              else
                if stringMap.has_key?(key)
                  rc += "\n  l.store \"#{key}\",#{stringMap[key]}"
                  stringMap.delete(key)
                else
                  rc += "\n  l.store \"#{key}\", \"\""
                end
              end
            end
          end
        end
      end
      if stringMap.size > 0
        rc += "\n\n  # Obsolete translations"
        stringMap.keys.sort.each do |key|
          rc += "\n  l.store \"#{key}\",#{stringMap[key]}"
        end
      end
      rc += "\nend\n"
      ff = File.new(filename,"w")
      ff.write(rc)
      ff.close()
    end
  end
end

class Tool
  def initialize
    @language  = 'en_US'
    @duplicate = true

{'fraction_non_alphanumeric': 0.169400376445281, 'fraction_numerical': 0.0032266738370529714, 'mean_word_length': 1.540983606557377, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7143429', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1167, 'n_words': 259}