<commit_before>package grok.core;

import java.util.Arrays;
import java.util.List;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.SetMultimap;

/**
 * @see <a href="http://www.mec.ca/AST/ContentPrimary/Learn/Climbing/IntroToClimbing/ClimbingGradeConversion.jsp"></a>
 */
@AutoValue
public abstract class ClimbingGrade implements Comparable<ClimbingGrade> {
  public enum Country {
    USA, FRANCE, AUSTRALIA, SOUTH_AFRICA, GERMANY, UNITED_KINGDOM;
  }

  public static ClimbingGrade of(Country country, String value) {
    for (ClimbingGrade maybe : KNOWN) {
      if (maybe.matches(country, value)) {
        return maybe;
      }
    }
    throw new IllegalArgumentException(value + " does not exist for " + country);
  }

  //@formatter:off
  private static final List<ClimbingGrade> KNOWN = Arrays.asList(
      known("5.1",   "2",      "7",     "8",     "III-",       "M"),
      known("5.2",   "2+",     "8",     "9",     "III",        "D"),
      known("5.3",   "3",      "9/10",  "10",    "III+",       "VD 3a"),
      known("5.4",   "3+",     "11",    "12",    "IV-",        "VD/HVD 3b"),
      known("5.5",   "4",      "12",    "13",    "IV",         "HVD/S 3c"),
      known("5.6",   "4+",     "13",    "14",    "IV+/V-",     "MS 4a"),
      known("5.7",   "5a",     "14/15", "15",    "V-/V",       "S/HS 4b"),
      known("5.8",   "5b",     "15/16", "16",    "V+/VI-",     "HS/VS 4b"),
      known("5.9",   "5c",     "17",    "17/18", "VI-/VI",     "HVS 4c"),
      known("5.10a", "6a",     "18",    "19",    "VI/VI+",     "HVS 5a"),
      known("5.10b", "6a+",    "19",    "20",    "VII-",       "E1 5a"),
      known("5.10c", "6b",     "20",    "21",    "VII-/VII",   "E1 5b"),<commit_msg>ClimbingGrade: add convenience usa() method<commit_after>package grok.core;

import java.util.Arrays;
import java.util.List;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.SetMultimap;

/**
 * @see <a href="http://www.mec.ca/AST/ContentPrimary/Learn/Climbing/IntroToClimbing/ClimbingGradeConversion.jsp"></a>
 */
@AutoValue
public abstract class ClimbingGrade implements Comparable<ClimbingGrade> {
  public enum Country {
    USA, FRANCE, AUSTRALIA, SOUTH_AFRICA, GERMANY, UNITED_KINGDOM;
  }

  public static ClimbingGrade usa(String value) {
    return of(Country.USA, value);
  }

  public static ClimbingGrade of(Country country, String value) {
    for (ClimbingGrade maybe : KNOWN) {
      if (maybe.matches(country, value)) {
        return maybe;
      }
    }
    throw new IllegalArgumentException(value + " does not exist for " + country);
  }

  //@formatter:off
  private static final List<ClimbingGrade> KNOWN = Arrays.asList(
      known("5.1",   "2",      "7",     "8",     "III-",       "M"),
      known("5.2",   "2+",     "8",     "9",     "III",        "D"),
      known("5.3",   "3",      "9/10",  "10",    "III+",       "VD 3a"),
      known("5.4",   "3+",     "11",    "12",    "IV-",        "VD/HVD 3b"),
      known("5.5",   "4",      "12",    "13",    "IV",         "HVD/S 3c"),
      known("5.6",   "4+",     "13",    "14",    "IV+/V-",     "MS 4a"),
      known("5.7",   "5a",     "14/15", "15",    "V-/V",       "S/HS 4b"),
      known("5.8",   "5b",     "15/16", "16",    "V+/VI-",     "HS/VS 4b"),
      known("5.9",   "5c",     "17",    "17/18", "VI-/VI",     "HVS 4c"),
      known("5.10a", "6a",     "18",    "19",    "VI/VI+",     "HVS 5a"),
      known("5.10b", "6a+",    "19",    "20",    "VII-",       "E1 5a"),
      known("5.10c", "6b",     "20",    "21",    "VII-/VII",   "E1 5b"),
{'fraction_non_alphanumeric': 0.2102981029810298, 'fraction_numerical': 0.055284552845528454, 'mean_word_length': 2.2577228596646073, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '370162', 'n_tokens_mistral': 1557, 'n_tokens_neox': 1445, 'n_words': 299}