<commit_before>(ns pig-latin
  (:require [clojure.string :as str]))

(defn starts-with-any [prefixes]
  (fn [word]
    (some (partial str/starts-with? word) prefixes)))

(defn- starts-with-vowel-like? [word]
  ((starts-with-any #{"yt" "xr"}) word))

(defn starts-with-vowel? [word]
  ((starts-with-any #{"a" "e" "i" "o" "u"}) word))

(defn- starts-with-two-letter-prefix? [word]
  ((starts-with-any #{"ch" "qu" "th"}) word))

(defn- starts-with-three-letter-prefix? [word]
  ((starts-with-any #{"thr" "sch"}) word))

(defn- starts-with-qu-and-preceeding-constanant? [word]
  (and (not (starts-with-vowel? word))
       (str/starts-with? (subs word 1) "qu")))

(defn rotate [word n]
  (str (subs word n) (subs word 0 n)))

(defn- translate-word [word]
  (cond
    (or (starts-with-vowel? word)
        (starts-with-vowel-like? word))
    (str word "ay")

    (or
     (starts-with-three-letter-prefix? word)
     (starts-with-qu-and-preceeding-constanant? word))
    (str (rotate word 3) "ay")

    (starts-with-two-letter-prefix? word)
    (str (rotate word 2) "ay")

    :else
    (str (rotate word 1) "ay")))
<commit_msg>refactor to make rotate method private and change starts-with-any method to no longer return a function<commit_after>(ns pig-latin
  (:require [clojure.string :as str]))

(defn starts-with-any [prefixes word]
  (some (partial str/starts-with? word) prefixes))

(defn- starts-with-vowel-like? [word]
  (starts-with-any #{"yt" "xr"} word))

(defn starts-with-vowel? [word]
  (starts-with-any #{"a" "e" "i" "o" "u"} word))

(defn- starts-with-two-letter-prefix? [word]
  (starts-with-any #{"ch" "qu" "th"} word))

(defn- starts-with-three-letter-prefix? [word]
  (starts-with-any #{"thr" "sch"} word))

(defn- starts-with-qu-and-preceeding-constanant? [word]
  (and (not (starts-with-vowel? word))
       (str/starts-with? (subs word 1) "qu")))

(defn- rotate [word n]
  (str (subs word n) (subs word 0 n)))

(defn append-ay [word]
  (str word "ay"))

(defn- translate-word [word]
  (cond
    (or (starts-with-vowel? word)
        (starts-with-vowel-like? word))
    (append-ay word)

    (or
     (starts-with-three-letter-prefix? word)
     (starts-with-qu-and-preceeding-constanant? word))
    (append-ay (rotate word 3))

    (starts-with-two-letter-prefix? word)
    (append-ay (rotate word 2))

    :else
    (append-ay (rotate word 1))))

{'fraction_non_alphanumeric': 0.19534883720930232, 'fraction_numerical': 0.004228329809725159, 'mean_word_length': 3.3977695167286246, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2473399', 'n_tokens_mistral': 998, 'n_tokens_neox': 968, 'n_words': 230}