<commit_before>require 'yaml'
require 'open-uri'

URL = "https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml"

# All the names will be changed to be readeable for css
def to_css_name(e)
  # Downcase the name
  css_name = e.downcase
  # Change the spaces for -
  css_name = css_name.gsub(/\s/, '-')
  # Change ' for -
  css_name = css_name.gsub(/\'/, '-')
  # Change # for -sharp
  css_name = css_name.gsub(/\#/, '-sharp')
  # Change + for p
  css_name = css_name.gsub(/\+/, 'p')
end

# Load YAML file
yalm_hash = YAML.load_file(open(URL))

# Open CSS file
css_file = File.open("github-colors.css", "w")

yalm_hash.map do |e, i|
  unless i["color"].nil?
    # Add comment with language name
    css_file.write("/* #{e} */\n")
    # Change programming language name
    css_name = to_css_name(e);
    # Adding css background-color class
    css_file.write(".ghc-#{css_name}-bg { background-color: #{i['color']}; }\n")
    # Adding css color class
    css_file.write(".ghc-#{css_name} { color: #{i['color']}; }\n")
  end
end

# Close file
css_file.close<commit_msg>Change order of lines to be more redeable<commit_after>require 'yaml'
require 'open-uri'

URL = "https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml"

# All the names will be changed to be readeable for css
def to_css_name(e)
  # Downcase the name
  css_name = e.downcase
  # Change the spaces for -
  css_name = css_name.gsub(/\s/, '-')
  # Change ' for -
  css_name = css_name.gsub(/\'/, '-')
  # Change # for -sharp
  css_name = css_name.gsub(/\#/, '-sharp')
  # Change + for p
  css_name = css_name.gsub(/\+/, 'p')
end

# Load YAML file
yalm_hash = YAML.load_file(open(URL))

# Open CSS file
css_file = File.open("github-colors.css", "w")

yalm_hash.map do |e, i|
  unless i["color"].nil?
    # Add comment with language name
    css_file.write("/* #{e} */\n")
    # Change programming language name
    css_name = to_css_name(e);
    # Adding css color class
    css_file.write(".ghc-#{css_name} { color: #{i['color']}; }\n")
    # Adding css background-color class
    css_file.write(".ghc-#{css_name}-bg { background-color: #{i['color']}; }\n")
  end
end

# Close file
css_file.close
{'fraction_non_alphanumeric': 0.16606498194945848, 'fraction_numerical': 0.0, 'mean_word_length': 3.3988095238095237, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6446812', 'n_tokens_mistral': 841, 'n_tokens_neox': 828, 'n_words': 204}