mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Autoformat
This commit is contained in:
@ -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"))
|
||||
|
||||
|
@ -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 ✔
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
Reference in New Issue
Block a user