Skip to main content

Module rules

Module rules 

Source
Expand description

Fuzzy rules over a reply: what -r rules.toml reads. Jev’s answers are degrees from 0 to 1 — a Noul’s probability of yes, each Score level’s and each Choice option’s probability — and the rules combine them with AND, OR, NOT and hedges into a score per outcome, which counts as a yes at or over a threshold.

[logic]                    # optional
and = "min"                # min | product | lukasiewicz
or  = "max"                # max | probsum | bounded

[decide]                   # optional
threshold = 0.5

[terms]                    # the names rules use for the answers
hot     = "temp.Hot"       # a Score's level, by its text
stormy  = "sky.storm"      # a Choice's option
raining = "raining"        # a Noul, by its id alone

[[rule]]
if     = "raining AND NOT SOMEWHAT hot"
then   = "raincoat"
weight = 1.0               # optional; the rule's score is multiplied by it

Operators are uppercase (AND, OR, NOT, and the hedges VERY, SOMEWHAT, EXTREMELY, INDEED) and terms are lowercase, so neither can be taken for the other. Hedges and NOT bind tightest, then AND, then OR, and parentheses group. Rules with the same then are joined by the file’s OR.

A rules file is checked against the questions before anything is asked (Rules::parse), so a term naming a level the question doesn’t have costs no call.

Structs§

Fired
One rule’s part in an item’s score.
Item
One then: its score, whether that reaches the threshold, and the rules that gave it.
Logic
The file’s [logic]: which AND and which OR.
Outcome
What the rules made of a reply.
OutputValue
An output’s crisp value: the centroid of its sets, each clipped at the score its rules give it.
Rules
A rules file, parsed and checked against the questions it will read.
SetScore
One set of an output: the score its rules clip it at (joined by the file’s OR), and those rules.

Enums§

And
How AND joins two degrees.
Or
How OR joins two degrees, in a rule and between rules with the same then.