-
Notifications
You must be signed in to change notification settings - Fork 49
PrettyPFA Titus Functions
Jim Pivarski edited this page Jul 16, 2015
·
1 revision
The titus.prettypfa
module has functions for generating PFA at any stage of its life cycle.
-
json(ppfa, lineNumbers=True, check=True)
: construct JSON text from PrettyPFA textppfa
. IflineNumbers
isFalse
, don't include line numbers. Ifcheck
isFalse
, don't verify that the resulting PFA is syntactically and semantically valid. This can be useful for generating invalid PFA that is later made valid by inserting a subtree. -
jsonNode(ppfa, lineNumbers=True, check=True)
: construct a Python dictionary of Python lists, strings, and numbers from PrettyPFA textppfa
. This form can be immediately modified by a Python algorithm. -
ast(ppfa, check=True)
: construct an abstract syntax tree from PrettyPFA textppfa
. This tree is a suite of nested specialized class instances for each PFA form. It can be used for modifications of the PFA that require more knowledge of the tree's structure. -
engine(ppfa, options=None, sharedState=None, multiplicity=1, style="pure", debug=False)
: construct a list of executable scoring engines from PrettyPFA textppfa
. The other options are the same astitus. genpy.PFAEngine.fromJson
.
Also, you may have noticed that the input and output type specifications in PrettyPFA are not Avro schema, unlike PFA. The intention is to make them easier to write. However, some datasets already have conventional Avro schema, so Titus has a function to convert Avro schema to PrettyPFA snippets.
-
avscToPretty(avsc, indent=0)
: construct a PrettyPFA text snippet fromavsc
, which is a Python dictionary of Python lists, strings, and numbers, representing an Avro schema. Theindent
is the starting indentation level.
If your Avro schema is stored in a file, you can use:
>>> import json
>>> avscToPretty(json.load(open(fileName)))
Return to the Hadrian wiki table of contents.
Licensed under the Hadrian Personal Use and Evaluation License (PUEL).