mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-04 14:15:59 +00:00
Only learn from confirmed items
Text classification should only learn from confirmed items. Log if classification is disabled when processing an item.
This commit is contained in:
parent
cb1a9e0699
commit
76ccfb8a81
@ -23,6 +23,11 @@ object ItemState {
|
|||||||
case object Created extends ItemState
|
case object Created extends ItemState
|
||||||
case object Confirmed extends ItemState
|
case object Confirmed extends ItemState
|
||||||
|
|
||||||
|
def premature: ItemState = Premature
|
||||||
|
def processing: ItemState = Processing
|
||||||
|
def created: ItemState = Created
|
||||||
|
def confirmed: ItemState = Confirmed
|
||||||
|
|
||||||
def fromString(str: String): Either[String, ItemState] =
|
def fromString(str: String): Either[String, ItemState] =
|
||||||
str.toLowerCase match {
|
str.toLowerCase match {
|
||||||
case "premature" => Right(Premature)
|
case "premature" => Right(Premature)
|
||||||
|
@ -157,8 +157,9 @@ object RegexNerFile {
|
|||||||
.reduce(_ ++ fr"UNION ALL" ++ _)
|
.reduce(_ ++ fr"UNION ALL" ++ _)
|
||||||
|
|
||||||
selectSimple(fr"MAX(t)", fr"(" ++ sql ++ fr") as x", Fragment.empty)
|
selectSimple(fr"MAX(t)", fr"(" ++ sql ++ fr") as x", Fragment.empty)
|
||||||
.query[Timestamp]
|
.query[Option[Timestamp]]
|
||||||
.option
|
.option
|
||||||
|
.map(_.flatten)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,11 +98,14 @@ object TextAnalysis {
|
|||||||
ctx: Context[F, Args],
|
ctx: Context[F, Args],
|
||||||
cfg: Config.TextAnalysis
|
cfg: Config.TextAnalysis
|
||||||
): OptionT[F, Ident] =
|
): OptionT[F, Ident] =
|
||||||
if (cfg.classification.enabled)
|
(if (cfg.classification.enabled)
|
||||||
OptionT(ctx.store.transact(RClassifierSetting.findById(ctx.args.meta.collective)))
|
OptionT(ctx.store.transact(RClassifierSetting.findById(ctx.args.meta.collective)))
|
||||||
.filter(_.enabled)
|
.filter(_.enabled)
|
||||||
.mapFilter(_.fileId)
|
.mapFilter(_.fileId)
|
||||||
else
|
else
|
||||||
OptionT.none
|
OptionT.none[F, Ident]).orElse(
|
||||||
|
OptionT.liftF(ctx.logger.info("Classification is disabled.")) *> OptionT
|
||||||
|
.none[F, Ident]
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -621,8 +621,14 @@ object QItem {
|
|||||||
collective: Ident,
|
collective: Ident,
|
||||||
chunkSize: Int
|
chunkSize: Int
|
||||||
): Stream[ConnectionIO, Ident] = {
|
): Stream[ConnectionIO, Ident] = {
|
||||||
val cols = Seq(RItem.Columns.id)
|
val cols = Seq(RItem.Columns.id)
|
||||||
(selectSimple(cols, RItem.table, RItem.Columns.cid.is(collective)) ++
|
val iColl = RItem.Columns.cid
|
||||||
|
val iState = RItem.Columns.state
|
||||||
|
(selectSimple(
|
||||||
|
cols,
|
||||||
|
RItem.table,
|
||||||
|
and(iColl.is(collective), iState.is(ItemState.confirmed))
|
||||||
|
) ++
|
||||||
orderBy(RItem.Columns.created.desc))
|
orderBy(RItem.Columns.created.desc))
|
||||||
.query[Ident]
|
.query[Ident]
|
||||||
.streamWithChunkSize(chunkSize)
|
.streamWithChunkSize(chunkSize)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user