Foresight.Recall.QueryAnalyzer (Foresight v0.1.0)

Copy Markdown View Source

Extracts a temporal constraint (a %{from: DateTime, to: DateTime} day/period range) from a natural-language query.

Native port of Hindsight's DateparserQueryAnalyzer._extract_period (query_analyzer.py:175-294): multilingual period expressions in EN/ES/IT/FR/DE (yesterday, today, "a few weeks ago", last week/month/year/weekend, "June 2024") plus explicit ISO dates. This is the always-available layer.

The 200+ language single-date tail (incl. Greek) is handled by the Python dateparser layer (C3b) which falls back to this module when unavailable.

Summary

Functions

Returns a %{from: DateTime, to: DateTime} range for the first temporal period found in query, resolved against reference (a DateTime), or nil.

Functions

analyze(query, reference, opts \\ [])

@spec analyze(String.t(), DateTime.t(), keyword()) ::
  %{from: DateTime.t(), to: DateTime.t()} | nil

Returns a %{from: DateTime, to: DateTime} range for the first temporal period found in query, resolved against reference (a DateTime), or nil.