Lemma.RuleResult (lemma_engine v0.9.1)

Copy Markdown View Source

One rule result from Lemma.run/3, as returned in Lemma.Response.results.

Value fields (measure, ratio, number, …) mirror the flattened Rust RuleResultValue. explanation is the raw explanation JSON map when present (tagged by "type"); pattern-match on that tag directly.

Summary

Functions

Builds a Lemma.RuleResult from one value of the decoded Lemma.run/3 JSON "results" map. Optional fields are absent (not null) from the API JSON when unset; Map.get/3 yields nil for those.

Types

t()

@type t() :: %Lemma.RuleResult{
  boolean: boolean() | nil,
  calendar: map() | nil,
  date: String.t() | nil,
  display: String.t() | nil,
  explanation: map() | nil,
  measure: %{optional(String.t()) => String.t()} | nil,
  missing_data: [String.t()] | nil,
  number: String.t() | nil,
  range: map() | nil,
  ratio: %{optional(String.t()) => String.t()} | nil,
  rule_type: String.t(),
  text: String.t() | nil,
  time: String.t() | nil,
  veto_reason: String.t() | nil,
  vetoed: boolean()
}

Functions

from_map(map)

@spec from_map(map()) :: t()

Builds a Lemma.RuleResult from one value of the decoded Lemma.run/3 JSON "results" map. Optional fields are absent (not null) from the API JSON when unset; Map.get/3 yields nil for those.