<commit_before>package fr.lium
package api

import java.io.File
import scala.util.{Try, Success, Failure}
import scala.util.matching.Regex

object AudioFileApi {

  def createAudioFile(tmpFile: File): Try[Int] = {
    Success(0)

  }
  def getNextFileId(dirs: List[File]): Option[Int] = {
    val regexp = """\d+""".r
    val maybeLastFile: Option[File] = dirs.filter(f => f.isDirectory && regexp.findFirstIn(f.getName).isDefined).sorted.lastOption

    maybeLastFile flatMap { f =>
        Try(f.getName.toInt) match {
          case Success(v) => Some(v + 1)
          case Failure(v) => None
        }
      }
  }

  def getNextFileId(dirs: Array[File]): Option[Int] = {
    getNextFileId(dirs.toList)

  }
  def getNextFileId(dir: File): Option[Int] = {
    for {
      files <- Option(dir.listFiles)
      id <- getNextFileId(files)
    } yield(id)
  }
}
<commit_msg>Prettify code<commit_after>package fr.lium
package api

import java.io.File
import scala.util.{Try, Success, Failure}
import scala.util.matching.Regex

object AudioFileApi {

  def createAudioFile(tmpFile: File): Try[Int] = {
    Success(0)

  }
  def getNextFileId(dirs: List[File]): Option[Int] = {
    val regexp = """\d+""".r
    val maybeLastFile: Option[File] = dirs.filter(f => f.isDirectory && regexp.findFirstIn(f.getName).isDefined).sorted.lastOption

    maybeLastFile flatMap { f => Try(f.getName.toInt).toOption.map(_+1) }
  }

  def getNextFileId(dirs: Array[File]): Option[Int] = getNextFileId(dirs.toList)

  def getNextFileId(dir: File): Option[Int] = Option(dir.listFiles) flatMap getNextFileId

}

{'fraction_non_alphanumeric': 0.14357682619647355, 'fraction_numerical': 0.0025188916876574307, 'mean_word_length': 3.63265306122449, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4792215', 'n_tokens_mistral': 591, 'n_tokens_neox': 566, 'n_words': 108}