Toplevel functions

Matching

jertl.match(structure, data)

Matches a structure to data.

Parameters
  • structure (str) – A pattern defining the structure to compare to data.

  • data ((Sequence | Mapping | Number)) – Python data to compare structure against

Returns

A description of the match

Return type

Optional(Match)

jertl.match_all(structure, data)

Generate all Matches of a structure to data.

Parameters
  • structure (str) – A pattern defining the structure to compare to the target data.

  • data ((Sequence | Mapping | Number)) – Python data to match

Yields

Match – All possible matches

jertl.compile_match(structure)

Compiles a structure pattern for later use.

Parameters

structure (str) – A pattern defining the structure to compare to the target data.

Returns

An object which can be used to match template to objects

Return type

Matcher

Filling

jertl.fill(structure, **bindings)

Populate a structure.

Parameters
  • structure (str) – A pattern defining the structure to compare to the target data.

  • **bindings (Dict[str, list | dict | str | Number]) – values for free variables referenced by template

Returns

A filled template

Return type

Dict | Sequence | Number

jertl.compile_fill(structure)

Compiles a structure for later filling.

Parameters

structure (str) – A pattern defining the structure to compare to the target data.

Returns

A filler

Return type

Filler

Transforming

jertl.transform(transform, data)

Matches a structure to data and fills a target structure.

Parameters
  • transform (str) – A pattern describing structures for matching and filling.

  • data (Dict | Sequence | Number) – Data to match against.

Returns

Optional(Transformer):: A Transformation

jertl.transform_all(transform, data)

Generate all Transforms of data given Transformation specification.

Parameters
  • transform (str) – A pattern describing structures for matching and filling.

  • data (KwArgs) – Data to match against.

Yields

Transformation – All possible transforms of the sources

jertl.compile_transform(transform)

Compiles a transform pattern for later reuse.

Parameters

transform (str) – Pattern describing a transform.

Returns

A transformer

Return type

Transformer

Collating

jertl.collate(collation, **bindings)

Match all matchers to targets

Parameters
  • collation (str) – Specification of collation.

  • **bindings (Dict[str, list | dict | str | Number]) – Data to match against.

Returns

A Collation

Return type

Optional(Collation)

jertl.collate_all(collation, **sources)

Yields all matches to targets

Parameters
  • collation (str) – Specification of collation.

  • **sources (Dict[str, list | dict | str | Number]) – Data to match against.

Yields

Collation – All possible collations

jertl.compile_collate(collation)

Compiles a template for later reuse.

Parameters
  • collation (str) – Specification of collation.

  • sources (Dict[str, list | dict | str | Number]) – Data to match against.

Returns

A collator

Return type

Collator

Inferring

jertl.infer(rule, **sources)

Applies a production rule agains sources and generates new data according to output structures

Parameters
  • rule (str) – Pattern describing a production rule.

  • **sources (Dict[str, list | dict | str | Number]) – Data to match against.

Returns

An inference

Return type

Optional(Inference)

jertl.infer_all(rule, **sources)

Generate all application of rule.

Parameters
  • rule (str) – Pattern describing a production rule.

  • **sources (Dict[str, list | dict | str | Number]) – Data to match against.

Yields

Inference – All possible inferences

jertl.compile_rule(rule)

Compiles a inference rule for later reuse.

Parameters

rule (str) – Pattern describing a production rule.

Returns

A rule

Return type

Rule