<commit_before>package com.wcaokaze.japanecraft

class Dictionary(map: Map<String, String>) {
  private val dictionary = map.toTrie()

  operator fun get(rawString: String): Pair<String, IntRange> {
    throw NotImplementedError()
  }
}<commit_msg>implemented<commit_after>package com.wcaokaze.japanecraft

class Dictionary(map: Map<String, String>) {
  private val trie = map.toTrie()

  operator fun get(rawString: String): Pair<String, IntRange>? {
    fun loop(prevNode: Trie<String>, index: Int): Pair<String, IntRange>? {
      if (index !in rawString.indices) return null
      val node = trie[rawString[index]] ?: return null

      if (node.value != null) {
        return loop(node, index + 1) ?: Pair(node.value!!, 0..index)
      } else {
        return loop(node, index + 1)
      }
    }

    return loop(trie, 0)
  }
}
{'fraction_non_alphanumeric': 0.13205282112845138, 'fraction_numerical': 0.004801920768307323, 'mean_word_length': 3.6077348066298343, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6435872', 'n_tokens_mistral': 286, 'n_tokens_neox': 274, 'n_words': 69}