<commit_before>package lila.base

import java.util.concurrent.TimeUnit
import scala.concurrent.duration._
import scala.concurrent.Future
import scala.util.Try

import com.typesafe.config.Config
import org.joda.time.{ DateTime, Duration }
import ornicar.scalalib.Zero
import scalaz._
import Scalaz._

import LilaTypes._

final class PimpedOption[A](private val self: Option[A]) extends AnyVal {

  import scalaz.std.{ option => o }

  def fold[X](some: A => X, none: => X): X = self.fold(none)(some)

  def |(a: => A): A = self getOrElse a

  def unary_~(implicit z: Zero[A]): A   = self getOrElse z.zero
  def orDefault(implicit z: Zero[A]): A = self getOrElse z.zero

  def toSuccess[E](e: => E): scalaz.Validation[E, A] = o.toSuccess(self)(e)

  def toFailure[B](b: => B): scalaz.Validation[A, B] = o.toFailure(self)(b)

  def toTryWith(err: => Exception): Try[A] =
    self.fold[Try[A]](scala.util.Failure(err))(scala.util.Success.apply)

  def toTry(err: => String): Try[A] = toTryWith(lila.base.LilaException(err))

  def err(message: => String): A = self.getOrElse(sys.error(message))

  def ifNone(n: => Unit): Unit = if (self.isEmpty) n

  def has(a: A) = self contains a
}

final class PimpedString(private val s: String) extends AnyVal {

  def replaceIf(t: Char, r: Char): String =
    if (s.indexOf(t) >= 0) s.replace(t, r) else s

  def replaceIf(t: Char, r: CharSequence): String =
    if (s.indexOf(t) >= 0) s.replace(String.valueOf(t), r) else s
<commit_msg>String.indexOf: the type of the char argument is `int`. Whatever.<commit_after>package lila.base

import java.util.concurrent.TimeUnit
import scala.concurrent.duration._
import scala.concurrent.Future
import scala.util.Try

import com.typesafe.config.Config
import org.joda.time.{ DateTime, Duration }
import ornicar.scalalib.Zero
import scalaz._
import Scalaz._

import LilaTypes._

final class PimpedOption[A](private val self: Option[A]) extends AnyVal {

  import scalaz.std.{ option => o }

  def fold[X](some: A => X, none: => X): X = self.fold(none)(some)

  def |(a: => A): A = self getOrElse a

  def unary_~(implicit z: Zero[A]): A   = self getOrElse z.zero
  def orDefault(implicit z: Zero[A]): A = self getOrElse z.zero

  def toSuccess[E](e: => E): scalaz.Validation[E, A] = o.toSuccess(self)(e)

  def toFailure[B](b: => B): scalaz.Validation[A, B] = o.toFailure(self)(b)

  def toTryWith(err: => Exception): Try[A] =
    self.fold[Try[A]](scala.util.Failure(err))(scala.util.Success.apply)

  def toTry(err: => String): Try[A] = toTryWith(lila.base.LilaException(err))

  def err(message: => String): A = self.getOrElse(sys.error(message))

  def ifNone(n: => Unit): Unit = if (self.isEmpty) n

  def has(a: A) = self contains a
}

final class PimpedString(private val s: String) extends AnyVal {

  def replaceIf(t: Char, r: Char): String =
    if (s.indexOf(t.toInt) >= 0) s.replace(t, r) else s

  def replaceIf(t: Char, r: CharSequence): String =
    if (s.indexOf(t.toInt) >= 0) s.replace(String.valueOf(t), r) else s

{'fraction_non_alphanumeric': 0.15670650730411687, 'fraction_numerical': 0.0013280212483399733, 'mean_word_length': 4.276707530647986, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '2881928', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1086, 'n_words': 291}