Autoformat

This commit is contained in:
Eike Kettner
2020-09-09 00:29:32 +02:00
parent 570b7de43f
commit c658677032
34 changed files with 279 additions and 319 deletions

View File

@ -26,18 +26,17 @@ object Domain {
Tld
.findTld(str)
.map(tld => (str.dropRight(tld.length), tld))
.map({
case (names, tld) =>
names.split('.').toList match {
case Nil => Left(s"Not a domain: $str")
case segs
if segs.forall(label =>
label.trim.nonEmpty && label
.forall(c => c.isLetter || c.isDigit || c == '-')
) =>
Right(Domain(NonEmptyList.fromListUnsafe(segs), tld))
case _ => Left(s"Not a domain: $str")
}
.map({ case (names, tld) =>
names.split('.').toList match {
case Nil => Left(s"Not a domain: $str")
case segs
if segs.forall(label =>
label.trim.nonEmpty && label
.forall(c => c.isLetter || c.isDigit || c == '-')
) =>
Right(Domain(NonEmptyList.fromListUnsafe(segs), tld))
case _ => Left(s"Not a domain: $str")
}
})
.getOrElse(Left(s"Not a domain $str"))

View File

@ -39,14 +39,14 @@ object DateFind {
}
private object SimpleDate {
val p0 = (readYear >> readMonth >> readDay).map {
case ((y, m), d) => SimpleDate(y, m, d)
val p0 = (readYear >> readMonth >> readDay).map { case ((y, m), d) =>
SimpleDate(y, m, d)
}
val p1 = (readDay >> readMonth >> readYear).map {
case ((d, m), y) => SimpleDate(y, m, d)
val p1 = (readDay >> readMonth >> readYear).map { case ((d, m), y) =>
SimpleDate(y, m, d)
}
val p2 = (readMonth >> readDay >> readYear).map {
case ((m, d), y) => SimpleDate(y, m, d)
val p2 = (readMonth >> readDay >> readYear).map { case ((m, d), y) =>
SimpleDate(y, m, d)
}
// ymd ✔, ydm, dmy ✔, dym, myd, mdy ✔

View File

@ -145,10 +145,9 @@ final class StanfordTextClassifier[F[_]: Sync: ContextShift](
def prepend(pre: String, data: Map[String, String]): Map[String, String] =
data.toList
.map({
case (k, v) =>
if (k.startsWith(pre)) (k, v)
else (pre + k, v)
.map({ case (k, v) =>
if (k.startsWith(pre)) (k, v)
else (pre + k, v)
})
.toMap
}

View File

@ -29,9 +29,8 @@ object StanfordTextClassifierSuite extends SimpleTestSuite {
.repeat
.take(10)
)
.flatMap({
case (a, b) =>
Stream.emits(Seq(a, b))
.flatMap({ case (a, b) =>
Stream.emits(Seq(a, b))
})
.covary[IO]
@ -53,23 +52,22 @@ object StanfordTextClassifierSuite extends SimpleTestSuite {
} yield (dir, blocker)
things
.use {
case (dir, blocker) =>
val classifier = new StanfordTextClassifier[IO](cfg, blocker)
.use { case (dir, blocker) =>
val classifier = new StanfordTextClassifier[IO](cfg, blocker)
val modelFile = dir.resolve("test.ser.gz")
for {
_ <-
LenientUri
.fromJava(getClass.getResource("/test.ser.gz"))
.readURL[IO](4096, blocker)
.through(fs2.io.file.writeAll(modelFile, blocker))
.compile
.drain
model = ClassifierModel(modelFile)
cat <- classifier.classify(logger, model, "there is receipt always")
_ = assertEquals(cat, Some("receipt"))
} yield ()
val modelFile = dir.resolve("test.ser.gz")
for {
_ <-
LenientUri
.fromJava(getClass.getResource("/test.ser.gz"))
.readURL[IO](4096, blocker)
.through(fs2.io.file.writeAll(modelFile, blocker))
.compile
.drain
model = ClassifierModel(modelFile)
cat <- classifier.classify(logger, model, "there is receipt always")
_ = assertEquals(cat, Some("receipt"))
} yield ()
}
.unsafeRunSync()
}