<commit_before>package com.sksamuel.elastic4s

import org.elasticsearch.common.xcontent.XContentBuilder

trait AnalyzerFilter {
  def name: String
}

trait AnalyzerFilterDefinition {
  def filterType: String
  def build(source: XContentBuilder): Unit
}

sealed trait CharFilter extends AnalyzerFilter

sealed trait CharFilterDefinition extends CharFilter with AnalyzerFilterDefinition

case object HtmlStripCharFilter extends CharFilter {
  val name = "html_strip"
}

case class MappingCharFilter(val name: String, mappings: (String, String)*)
    extends CharFilterDefinition {

  val filterType = "mapping"

  def build(source: XContentBuilder): Unit = {
    source.field("mappings", mappings.map({ case (k, v) => s"$k=>$v" }) toArray: _*)
  }

}

case class PatternReplaceCharFilter(val name: String, pattern: String, replacement: String)
    extends CharFilterDefinition {

  val filterType = "pattern_replace"

  def build(source: XContentBuilder): Unit = {
    source.field("pattern", pattern)
    source.field("replacement", replacement)
  }
}

<commit_msg>Tidied up char filter to remove redundant val in case class<commit_after>package com.sksamuel.elastic4s

import org.elasticsearch.common.xcontent.XContentBuilder

trait AnalyzerFilter {
  def name: String
}

trait AnalyzerFilterDefinition {
  def filterType: String
  def build(source: XContentBuilder): Unit
}

sealed trait CharFilter extends AnalyzerFilter

sealed trait CharFilterDefinition extends CharFilter with AnalyzerFilterDefinition

case object HtmlStripCharFilter extends CharFilter {
  val name = "html_strip"
}

case class MappingCharFilter(name: String, mappings: (String, String)*)
    extends CharFilterDefinition {

  val filterType = "mapping"

  def build(source: XContentBuilder): Unit = {
    source.field("mappings", mappings.map({ case (k, v) => s"$k=>$v"}).toArray: _*)
  }

}

case class PatternReplaceCharFilter(name: String, pattern: String, replacement: String)
    extends CharFilterDefinition {

  val filterType = "pattern_replace"

  def build(source: XContentBuilder): Unit = {
    source.field("pattern", pattern)
    source.field("replacement", replacement)
  }
}


{'fraction_non_alphanumeric': 0.0928406466512702, 'fraction_numerical': 0.0009237875288683603, 'mean_word_length': 5.224137931034483, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3397854', 'n_tokens_mistral': 641, 'n_tokens_neox': 628, 'n_words': 175}