<commit_before>package pl.writeonly.son2.main

import pl.writeonly.son2.core.chain.ChainNotationPair
import pl.writeonly.son2.core.glue.ProviderCreator
import pl.writeonly.son2.core.notation.{Config, NotationPair, NotationReader, NotationWriter}
import pl.writeonly.son2.core.providers.Provider
import pl.writeonly.son2.jack.chain.{ChainNotationPairJack, ChainReaderJack}
import pl.writeonly.son2.jack.core.ConfigJack
import pl.writeonly.son2.jack.glue.ProviderCreatorJack
import pl.writeonly.son2.path.chain.ChainNotationPairPath
import pl.writeonly.son2.path.core.ConfigPath
import pl.writeonly.son2.path.creators.PartialCreatorPath

class Mainer(params: Params, args: Array[String]) {
  val length = args.length

  def either = option match {
    case Right(provider) => new Piper(params, provider).right(args.slice(1, length))
    case Left(format) => new Resourcer(params).left(format)
  }

  def option: Either[Option[String], Provider] = length match {
    case 0 => Left(Option.empty)
    case _ => provider(args(0).toLowerCase)
  }

  def provider(s: String): Either[Option[String], Provider] = s match {
    case s if new PartialCreatorPath().isDefinedAt(s) => Right(p(ConfigPath(i = s)))
    case s => ProviderCreatorJack.either(ConfigJack(o = s))
  }

  def provider2(s: String): Either[Option[String], Provider] = chain(s)
    .map(p => Right(p))
    .getOrElse(Left(Option(s)))

  def chain(s:String) : Option[Provider] = chain(false)
    .lift(s).map(t => t.c)
    .map(f => f(s))
    .map(provider)

  def chain(p : Boolean) : PartialFunction[String, NotationPair] = (
    new ChainNotationPairPath(p).get
      orElse
      new ChainNotationPairJack(p).get
    )

  def provider(c : Config) = new Provider(c, input(c), output(c))

  def input(c :Config):NotationReader = chain(c.p).lift(c.i).map(f => f.r).get

  def output(c :Config):NotationWriter = chain(c.p).lift(c.o).map(f => f.w).get

  def p(c: Config) = ProviderCreator.provider(c, path(c), jack(c))

  def path(c: Config): ChainNotationPair = new ChainNotationPairPath(c.p)

  def jack(c: Config): ChainNotationPair = new ChainNotationPairJack(c.p)

  def reader = new ChainReaderJack()

}
<commit_msg>Update Mainer.scala<commit_after>package pl.writeonly.son2.main

import pl.writeonly.son2.core.chain.ChainNotationPair
import pl.writeonly.son2.core.glue.ProviderCreator
import pl.writeonly.son2.core.notation.{Config, NotationPair, NotationReader, NotationWriter}
import pl.writeonly.son2.core.providers.Provider
import pl.writeonly.son2.jack.chain.{ChainNotationPairJack, ChainReaderJack}
import pl.writeonly.son2.jack.core.ConfigJack
import pl.writeonly.son2.jack.glue.ProviderCreatorJack
import pl.writeonly.son2.path.chain.ChainNotationPairPath
import pl.writeonly.son2.path.core.ConfigPath
import pl.writeonly.son2.path.creators.PartialCreatorPath

class Mainer(params: Params, args: Array[String]) {
  val length = args.length

  def either = option match {
    case Right(provider) => new Piper(params, provider).right(args.slice(1, length))
    case Left(format) => new Resourcer(params).left(format)
  }

  def option: Either[Option[String], Provider] = length match {
    case 0 => Left(Option.empty)
    case _ => provider(args(0).toLowerCase)
  }

  def provider2(s: String): Either[Option[String], Provider] = s match {
    case s if new PartialCreatorPath().isDefinedAt(s) => Right(p(ConfigPath(i = s)))
    case s => ProviderCreatorJack.either(ConfigJack(o = s))
  }

  def provider(s: String): Either[Option[String], Provider] = chain(s)
    .map(p => Right(p))
    .getOrElse(Left(Option(s)))

  def chain(s:String) : Option[Provider] = chain(false)
    .lift(s).map(t => t.c)
    .map(f => f(s))
    .map(provider)

  def chain(p : Boolean) : PartialFunction[String, NotationPair] = (
    new ChainNotationPairPath(p).get
      orElse
      new ChainNotationPairJack(p).get
    )

  def provider(c : Config) = new Provider(c, input(c), output(c))

  def input(c :Config):NotationReader = chain(c.p).lift(c.i).map(f => f.r).get

  def output(c :Config):NotationWriter = chain(c.p).lift(c.o).map(f => f.w).get

  def p(c: Config) = ProviderCreator.provider(c, path(c), jack(c))

  def path(c: Config): ChainNotationPair = new ChainNotationPairPath(c.p)

  def jack(c: Config): ChainNotationPair = new ChainNotationPairJack(c.p)

  def reader = new ChainReaderJack()

}

{'fraction_non_alphanumeric': 0.1413840513290559, 'fraction_numerical': 0.0068744271310724105, 'mean_word_length': 4.646830530401035, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '6539310', 'n_tokens_mistral': 1548, 'n_tokens_neox': 1498, 'n_words': 289}