<commit_before>package unfiltered.util

case class MIMEType(major: String, minor: String, params: Map[String, String] = Map.empty) {
  def includes(mt: MIMEType) = {
     this match {
	   case MIMEType.ALL => true
	   case MIMEType(maj, "*", _) => mt.major == maj
	   case MIMEType(maj, min, _) => mt.major == maj && mt.minor == min
     }	
  }
  override def toString = "%s/%s".format(major, minor) + params.map{case (a, b) => "; %s=%s".format(a, b)}.mkString("")
}

object MIMEType {
  val ALL = MIMEType("*", "*")

  val APPLICATION_ALL = MIMEType("application", "*")  
  val APPLICATION_ATOM = MIMEType("application", "atom+xml")
  val APPLICATION_ATOM_CATEGORY = MIMEType("application", "atomcat+xml")
  val APPLICATION_ATOM_SERVICE = MIMEType("application", "atomsvc+xml")
  val APPLICATION_OCTET_STREAM = MIMEType("application", "octet-stream")
  val APPLICATION_FORM_URLENCODED = MIMEType("application", "x-www-form-urlencoded")
  val APPLICATION_XML = MIMEType("application", "xml")  

  val IMAGE_ALL = MIMEType("image", "*")
  val IMAGE_JPEG = MIMEType("image", "jpeg")
  val IMAGE_PNG = MIMEType("image", "png")

  val MULTIPART_FORM_DATA = MIMEType("multipart", "form-data")

  val TEXT_HTML = MIMEType("text", "html")
  val TEXT_PLAIN = MIMEType("text", "plain")
  val TEXT_URI_LIST = MIMEType("text", "uri-list")
  
  val VIDEO_ALL = MIMEType("video", "*")
  val VIDEO_MP4 = MIMEType("video", "mp4")
  val VIDEO_MPEG = MIMEType("video", "mpeg")

  def apply(mt: String): Option[MIMEType] = {
    import javax.activation.MimeType
    import scala.collection.JavaConverters._
    try {
      val mimeType = new MimeType(mt)
      val names = mimeType.getParameters.getNames.asInstanceOf[java.util.Enumeration[String]].asScala
      val params = names.foldLeft(Map[String, String]())((acc, p) => acc + (p -> mimeType.getParameter(p)))
      Some(new MIMEType(mimeType.getPrimaryType, mimeType.getSubType, params))
    }
    catch {
      case _ => None
    }
  }

  def string2MIMEType(input: String) = apply(input).getOrElse(throw new IllegalArgumentException("Not a valid MIMEType"))
}
<commit_msg>Removed most constants. ALL => All which is the only required constant<commit_after>package unfiltered.util

case class MIMEType(major: String, minor: String, params: Map[String, String] = Map.empty) {
  def includes(mt: MIMEType) = {
     this match {
	   case MIMEType.All => true
	   case MIMEType(maj, "*", _) => mt.major == maj
	   case MIMEType(maj, min, _) => mt.major == maj && mt.minor == min
     }	
  }
  override def toString = "%s/%s".format(major, minor) + params.map{case (a, b) => "; %s=%s".format(a, b)}.mkString("")
}

object MIMEType {
  val All = MIMEType("*", "*")

  def apply(mt: String): Option[MIMEType] = {
    import javax.activation.MimeType
    import scala.collection.JavaConverters._
    try {
      val mimeType = new MimeType(mt)
      val names = mimeType.getParameters.getNames.asInstanceOf[java.util.Enumeration[String]].asScala
      val params = names.foldLeft(Map[String, String]())((acc, p) => acc + (p -> mimeType.getParameter(p)))
      Some(new MIMEType(mimeType.getPrimaryType, mimeType.getSubType, params))
    }
    catch {
      case _ => None
    }
  }

  def string2MIMEType(input: String) = apply(input).getOrElse(throw new IllegalArgumentException("Not a valid MIMEType"))
}

{'fraction_non_alphanumeric': 0.15308568004793288, 'fraction_numerical': 0.0011983223487118035, 'mean_word_length': 4.129032258064516, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 4}, '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': '6622019', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1199, 'n_words': 247}