naxp_compare() says how b stands to a: what happens to text and
encoded values held under a if b replaces it. naxp_first_divergent_value()
finds the lowest encoded value the two decode differently.
Arguments
- a
The naxp the data was encoded with: a naxp from
naxp_parse(), a pattern string or a naxp_encoded vector, whose naxp is used.- b
The naxp proposed to replace it, likewise.
- budget
NULLfor the library's default budget of 200 000 product states, or a positive whole number.
Value
naxp_compare(): a named character vector with elementsaccepted_text,encodingandcanonical_forms.naxp_first_divergent_value(): a single encoded value, or 0 where every value both naxps hold decodes alike. Values only one naxp holds do not count. It is an integer where both naxps' encoded values are integers, and otherwise a double.
Details
naxp_compare() gives three set relationships, each from a's point of
view:
accepted_text: how the stringsaaccepts stand to thosebaccepts.encoding: how the (text, encoded value) pairsadefines stand to thosebdefines. Replacingawithbis safe for stored values exactly when this is"equal"or"subset_of".canonical_forms: how the canonical formsaprints stand to thosebprints.
Each is "equal", "subset_of", "superset_of" or "incomparable".
The encoding relationship is decided by walking the two naxps together,
which has a budget. No naxp anybody has reason to write comes near the
default, but a pair that does cannot be decided, and naxp_compare() then
raises an error rather than guess.
Examples
with_space <- naxp_parse(r"(\9\9\9\9 \s!! \A\A)")
without_space <- naxp_parse(r"(\9\9\9\9 \s!? \A\A)")
naxp_compare(with_space, without_space)
#> accepted_text encoding canonical_forms
#> "equal" "equal" "incomparable"
naxp_first_divergent_value(with_space, without_space)
#> [1] 1