dateparser: python shell-out with two-step parse + russian qualifier pre-processing

PythonDateParser shells out to python3 with the dateparser library for
full natural-language date/time extraction. Two-step approach:
1. search_dates() finds the date substring in surrounding text
2. parse() re-parses the substring for correct time resolution

Russian time qualifiers (утра/вечера/дня/ночи) are pre-processed to
AM/PM before parsing — dateparser drops them during substring extraction.

Falls back to StubDateTimeParser when python3 or dateparser isn't
available (graceful degradation, no hard runtime dependency).

Dockerfile updated: python3 + dateparser==1.4.1 in runtime stage.
This commit is contained in:
kami
2026-07-06 19:09:09 +04:00
parent bf4009ca4f
commit d493be34b2
4 changed files with 277 additions and 3 deletions
+2 -2
View File
@@ -229,7 +229,7 @@ func wireVoice(cfg *config.Config, coreAPI ipc.CoreAPI, phr phraser.Phraser, mem
memStore: memStore,
dialogueSessions: dialogueSessions,
queryMinScore: cfg.Voice.QueryMinScore,
timeParser: router.StubDateTimeParser{},
timeParser: router.NewPythonDateParser(),
}
// ----- the server (TCP listener) -----
@@ -803,7 +803,7 @@ func buildRouter(emb router.Embedder, acts router.ActMatcher, threshold float64)
Grammars: grammars,
Classifier: cls,
Extractor: router.Extractor{
Time: router.StubDateTimeParser{},
Time: router.NewPythonDateParser(),
Acts: acts,
Facts: router.DefaultFactParser{},
},