Module tf.advanced.unravel
Unravel
Unraveling means to transform a neighbourhood of nodes into a tree of node fragment. That sounds simple, but quite a few ideas have to work together to make it work.
It is described at length in tf.about.displaydesign.
Functions
def unravel(app, n, isPlain=True, explain=False, **options)-
Expand source code Browse git
def unravel(app, n, isPlain=True, _inTuple=False, explain=False, **options): """Unravels a node and its graph-neighbourhood into a tree of fragments. Parameters ---------- n: integer The node to unravel. isPlain: boolean, optional True Whether to unravel for plain display. Otherwise it is for pretty display. The tree structure is the same for both, but the tree is also dressed up with formatting information, which may differ for both modes. explain: boolean or `'details'`: Whether to pretty-print the tree. If the value `details` is passed, most of the dressing information of the tree is also shown. **options: Any amount of legal display options. These will influence the dressing information. Returns ------- chunk: tuple `(node, (begin slot, end slot))` The top of the tree has `None` info: object dressing information in the form of key value pairs, among which: `options` (the display options that are in force), `settings` (properties of node independent properties), `props` (properties of the node of the chunk), `boundaryCls` (CSS info for the boundaries of the chunk). The top of the tree has only has options and settings. children: list subtrees where each subtree is again a tuple of chunk, info and children. """ display = app.display dContext = display.distill(options) return _unravel(app, not isPlain, dContext, n, _inTuple=_inTuple, explain=explain)Unravels a node and its graph-neighbourhood into a tree of fragments.
Parameters
n:integer- The node to unravel.
isPlain:boolean, optionalTrue- Whether to unravel for plain display. Otherwise it is for pretty display. The tree structure is the same for both, but the tree is also dressed up with formatting information, which may differ for both modes.
explain:booleanor`'details':`- Whether to pretty-print the tree.
If the value
detailsis passed, most of the dressing information of the tree is also shown.
**options: Any amount of legal display options. These will influence the dressing information.
Returns
chunk:tuple(node, (begin slot, end slot))The top of the tree hasNoneinfo:object- dressing information in the form of key value pairs, among which:
options(the display options that are in force),settings(properties of node independent properties),props(properties of the node of the chunk),boundaryCls(CSS info for the boundaries of the chunk). The top of the tree has only has options and settings. children:list- subtrees where each subtree is again a tuple of chunk, info and children.
Classes
class NodeProps (nType,
isSlot,
isSlotOrDescend,
descend,
isBaseNonSlot,
isLexType,
lexType,
lineNumberFeature,
featuresBare,
features,
textCls,
hlCls,
hlStyle,
cls,
hasGraphics,
after,
plainCustom)-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passNodeProps(nType, isSlot, isSlotOrDescend, descend, isBaseNonSlot, isLexType, lexType, lineNumberFeature, featuresBare, features, textCls, hlCls, hlStyle, cls, hasGraphics, after, plainCustom)
Ancestors
- builtins.tuple
Instance variables
var after-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passWhether the app defines a custom method to generate material after a child.It is a dict keyed by node type whose values are the custom methods.
var cls-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passA dict of several classes for the display of the node: for the container, the label, and the children of the node; might be set by prettyCustom
var descend-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passWhen calling T.text(n, descend=??) for this node, what should we substitute for the ?? ?
var features-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passFeatures to display in the labels of pretty displays with their names
var featuresBare-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passFeatures to display in the labels of pretty displays without their names
var hasGraphics-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passWhether this node type has graphics.
var hlCls-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passThe highlight Css class of the current node, both for pretty and plain modes, keyed by boolean 'is pretty'
var hlStyle-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passThe highlight Css color style of the current node, both for pretty and plain modes, keyed by boolean 'is pretty'
var isBaseNonSlot-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passWhether the current node has a type that is currently a baseType, i.e. a type where a pretty display should stop unfolding.
var isLexType-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passWhether nodes of type are lexemes.
var isSlot-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passWhether the current node is a slot node.
var isSlotOrDescend-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passWhether the current node is a slot node or has a type to which the current text format should descend. This type is determined by the current text format.
var lexType-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passIf nodes of this type have lexemes in another type, this is that type.
var lineNumberFeature-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passFeature with source line numbers of nodes of this type.
var nType-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passThe node type of the current node.
var plainCustom-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passWhether the app defines a custom method to plain displays for this node type.
var textCls-
Expand source code Browse git
class NodeProps: """Node properties during plain() or pretty(). """ passThe text Css class of the current node.
class OuterSettings (slotType,
ltr,
fmt,
textClsDefault,
textMethod,
getText,
upMethod,
slotsMethod,
fLookupMethod,
eLookupMethod,
allEFeats,
browsing,
webLink,
getGraphics)-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passOuterSettings(slotType, ltr, fmt, textClsDefault, textMethod, getText, upMethod, slotsMethod, fLookupMethod, eLookupMethod, allEFeats, browsing, webLink, getGraphics)
Ancestors
- builtins.tuple
Instance variables
var allEFeats-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passSet of all edge features:
tf.core.api.Api.Eall(warp=False) var browsing-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passwhether we work for the TF browser or for a Jupyter notebook
var eLookupMethod-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passMethod to get the value of an edge feature:
Api.Es() var fLookupMethod-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passMethod to get the value of a node feature:
Api.Fs() var fmt-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passthe currently selected text format.
var getGraphics-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passMethod to fetch graphics for a node. App-dependent.See
tf.advanced.settingsunder graphics. var getText-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passMethod to get the text for a node according to a template:
getText() var ltr-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passwriting direction.
var slotType-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passThe slot type of the dataset.
var slotsMethod-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passMethod to get the slots of a node:
OslotsFeature.s() var textClsDefault-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passDefault CSS class for full text.
var textMethod-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passMethod to print text of a node according to a text format:
Text.text() var upMethod-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passMethod to move from a node to its first embedder:
Locality.u() var webLink-
Expand source code Browse git
class OuterSettings: """Common properties during plain() and pretty(). """ passMethod to produce a web link to a node:
webLink()
class TreeInfo (**specs)-
Expand source code Browse git
class TreeInfo: """Tree properties during plain() or pretty(). Collects `NodeProps`, `OuterSettings`, and `tf.advanced.options`. """ def __init__(self, **specs): self.update(**specs) def update(self, **specs): for (k, v) in specs.items(): setattr(self, k, v) def get(self, k, v): return getattr(self, k, v)Tree properties during plain() or pretty().
Collects
NodeProps,OuterSettings, andtf.advanced.options.Methods
def get(self, k, v)-
Expand source code Browse git
def get(self, k, v): return getattr(self, k, v) def update(self, **specs)-
Expand source code Browse git
def update(self, **specs): for (k, v) in specs.items(): setattr(self, k, v)