<commit_before>package pureconfig.backend

import java.nio.file.Path

import scala.util.control.NonFatal

import com.typesafe.config._
import pureconfig._
import pureconfig.error._

/**
 * A wrapper of `com.typesafe.config.ConfigFactory` whose methods return [[scala.Either]] instead
 * of throwing exceptions
 */
object ConfigFactoryWrapper {
  private[this] val strictSettings = ConfigParseOptions.defaults.setAllowMissing(false)

  /** @see `com.typesafe.config.ConfigFactory.invalidateCaches()` */
  def invalidateCaches(): ConfigReader.Result[Unit] =
    unsafeToEither(ConfigFactory.invalidateCaches())

  /** @see `com.typesafe.config.ConfigFactory.load()` */
  def load(): ConfigReader.Result[Config] =
    unsafeToEither(ConfigFactory.load())

  /** @see `com.typesafe.config.ConfigFactory.parseString()` */
  def parseString(s: String): ConfigReader.Result[Config] =
    unsafeToEither(ConfigFactory.parseString(s))

  /** @see `com.typesafe.config.ConfigFactory.parseFile()` */
  def parseFile(path: Path): ConfigReader.Result[Config] =
    unsafeToEither(ConfigFactory.parseFile(path.toFile, strictSettings), Some(path))

  /** Utility methods that parse a file and then calls `ConfigFactory.load` */
  def loadFile(path: Path): ConfigReader.Result[Config] =
    parseFile(path).right.flatMap(rawConfig => unsafeToEither(ConfigFactory.load(rawConfig)))

  private def unsafeToEither[A](f: => A, path: Option[Path] = None): ConfigReader.Result[A] = {<commit_msg>Rename unsafeToEither to unsafeToReaderResult<commit_after>package pureconfig.backend

import java.nio.file.Path

import scala.util.control.NonFatal

import com.typesafe.config._
import pureconfig._
import pureconfig.error._

/**
 * A wrapper of `com.typesafe.config.ConfigFactory` whose methods return [[scala.Either]] instead
 * of throwing exceptions
 */
object ConfigFactoryWrapper {
  private[this] val strictSettings = ConfigParseOptions.defaults.setAllowMissing(false)

  /** @see `com.typesafe.config.ConfigFactory.invalidateCaches()` */
  def invalidateCaches(): ConfigReader.Result[Unit] =
    unsafeToReaderResult(ConfigFactory.invalidateCaches())

  /** @see `com.typesafe.config.ConfigFactory.load()` */
  def load(): ConfigReader.Result[Config] =
    unsafeToReaderResult(ConfigFactory.load())

  /** @see `com.typesafe.config.ConfigFactory.parseString()` */
  def parseString(s: String): ConfigReader.Result[Config] =
    unsafeToReaderResult(ConfigFactory.parseString(s))

  /** @see `com.typesafe.config.ConfigFactory.parseFile()` */
  def parseFile(path: Path): ConfigReader.Result[Config] =
    unsafeToReaderResult(ConfigFactory.parseFile(path.toFile, strictSettings), Some(path))

  /** Utility methods that parse a file and then calls `ConfigFactory.load` */
  def loadFile(path: Path): ConfigReader.Result[Config] =
    parseFile(path).right.flatMap(rawConfig => unsafeToReaderResult(ConfigFactory.load(rawConfig)))

  private def unsafeToReaderResult[A](f: => A, path: Option[Path] = None): ConfigReader.Result[A] = {
{'fraction_non_alphanumeric': 0.1320504313205043, 'fraction_numerical': 0.0, 'mean_word_length': 5.6118421052631575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2560782', 'n_tokens_mistral': 915, 'n_tokens_neox': 867, 'n_words': 167}