mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-02-15 20:33:26 +00:00
Improve logging
This commit is contained in:
parent
27c24c128d
commit
b12d965223
@ -25,8 +25,9 @@ object Classify {
|
||||
text: String
|
||||
)(cname: ClassifierName): F[Option[String]] =
|
||||
(for {
|
||||
_ <- OptionT.liftF(logger.info(s"Guessing label for ${cname.name} …"))
|
||||
_ <- OptionT.liftF(logger.info(s"Guessing label for ${cname.name} …"))
|
||||
model <- OptionT(store.transact(RClassifierModel.findByName(coll, cname.name)))
|
||||
.flatTapNone(logger.debug("No classifier model found."))
|
||||
modelData =
|
||||
store.bitpeace
|
||||
.get(model.fileId.id)
|
||||
@ -40,6 +41,7 @@ object Classify {
|
||||
.drain
|
||||
.flatMap(_ => classifier.classify(logger, ClassifierModel(modelFile), text))
|
||||
}).filter(_ != LearnClassifierTask.noClass)
|
||||
.flatTapNone(logger.debug("Guessed: <none>"))
|
||||
_ <- OptionT.liftF(logger.debug(s"Guessed: ${cls}"))
|
||||
} yield cls).value
|
||||
|
||||
|
@ -37,8 +37,7 @@ object TextAnalysis {
|
||||
_ <- t.traverse(m =>
|
||||
ctx.store.transact(RAttachmentMeta.updateLabels(m._1.id, m._1.nerlabels))
|
||||
)
|
||||
e <- s
|
||||
_ <- ctx.logger.info(s"Text-Analysis finished in ${e.formatExact}")
|
||||
|
||||
v = t.toVector
|
||||
autoTagEnabled <- getActiveAutoTag(ctx, cfg)
|
||||
tag <-
|
||||
@ -50,6 +49,8 @@ object TextAnalysis {
|
||||
predictItemEntities(ctx, cfg, item.metas, analyser.classifier)
|
||||
else MetaProposalList.empty.pure[F]
|
||||
|
||||
e <- s
|
||||
_ <- ctx.logger.info(s"Text-Analysis finished in ${e.formatExact}")
|
||||
} yield item
|
||||
.copy(
|
||||
metas = v.map(_._1),
|
||||
@ -109,7 +110,6 @@ object TextAnalysis {
|
||||
mtype: MetaProposalType
|
||||
): F[Option[MetaProposal]] =
|
||||
for {
|
||||
_ <- ctx.logger.debug(s"Guessing $mtype using classifier")
|
||||
label <- makeClassify(ctx, cfg, classifier)(text).apply(cname)
|
||||
} yield label.map(str =>
|
||||
MetaProposal(mtype, Candidate(IdRef(Ident.unsafe(""), str), Set.empty))
|
||||
|
@ -46,10 +46,14 @@ object TextExtraction {
|
||||
)
|
||||
_ <- fts.indexData(ctx.logger, (idxItem +: txt.map(_.td)).toSeq: _*)
|
||||
dur <- start
|
||||
_ <- ctx.logger.info(s"Text extraction finished in ${dur.formatExact}")
|
||||
extractedTags = txt.flatMap(_.tags).distinct.toList
|
||||
_ <- ctx.logger.info(s"Text extraction finished in ${dur.formatExact}.")
|
||||
_ <-
|
||||
if (extractedTags.isEmpty) ().pure[F]
|
||||
else ctx.logger.debug(s"Found tags in file: $extractedTags")
|
||||
} yield item
|
||||
.copy(metas = txt.map(_.am))
|
||||
.appendTags(txt.flatMap(_.tags).distinct.toList)
|
||||
.appendTags(extractedTags)
|
||||
}
|
||||
|
||||
// -- helpers
|
||||
|
Loading…
Reference in New Issue
Block a user