<commit_before>package x7c1.wheat.build

import sbt.complete.Parser


object ResourceNameParser {
  import sbt.complete.DefaultParsers._

  def readPrefix(name: String): Either[WheatParserError, ResourcePrefix] = {
    parse(name, parserToPrefix).left.map(WheatParserError).joinRight
  }

  def identifier = WheatParser.identifier

  def parserToPrefix: Parser[Either[WheatParserError, ResourcePrefix]] = {
    val wordsParser = identifier ~ (token('_') ~> identifier).* map {
      case (x, xs) => Words(x +: xs)
    }
    any.*.string <~ token(".xml") map { raw =>
      val p = "_".? ~ (wordsParser <~ token("__")).? ~ wordsParser map {
        case ((underscore, parent), words) =>
          val parentName = parent map (_.camelize)
          ResourcePrefix(
            raw = raw,
            ofClass = (underscore getOrElse "") + (parentName getOrElse "") + words.camelize,
            ofKey = raw + "__",
            parentClassName = for (u <- underscore; p <- parentName) yield u + p
          )
      }
      parse(raw, p).left map WheatParserError
    }
  }
  private case class Words(values: Seq[String]){
    def camelize = values.map(_.capitalize).mkString
  }
}<commit_msg>bugfix to generate parent ViewHolder<commit_after>package x7c1.wheat.build

import sbt.complete.Parser


object ResourceNameParser {

  import sbt.complete.DefaultParsers._

  def readPrefix(name: String): Either[WheatParserError, ResourcePrefix] = {
    parse(name, parserToPrefix).left.map(WheatParserError).joinRight
  }

  def identifier = WheatParser.identifier

  def parserToPrefix: Parser[Either[WheatParserError, ResourcePrefix]] = {
    val wordsParser = identifier ~ (token('_') ~> identifier).* map {
      case (x, xs) => Words(x +: xs)
    }
    any.*.string <~ token(".xml") map { raw =>
      val p = "_".? ~ (wordsParser <~ token("__")).? ~ wordsParser map {
        case ((underscore, parent), words) =>
          val parentName = parent map (_.camelize)
          val privatePrefix = underscore getOrElse ""
          ResourcePrefix(
            raw = raw,
            ofClass = privatePrefix + (parentName getOrElse "") + words.camelize,
            ofKey = raw + "__",
            parentClassName = parentName map (privatePrefix + _)
          )
      }
      parse(raw, p).left map WheatParserError
    }
  }

  private case class Words(values: Seq[String]) {
    def camelize = values.map(_.capitalize).mkString
  }

}
{'fraction_non_alphanumeric': 0.12680115273775217, 'fraction_numerical': 0.0016467682173734047, 'mean_word_length': 2.838862559241706, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6648283', 'n_tokens_mistral': 761, 'n_tokens_neox': 724, 'n_words': 170}