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, 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.

Classes

class NodeProps (nType,
isSlot,
isSlotOrDescend,
descend,
isBaseNonSlot,
isLexType,
lexType,
lineNumberFeature,
featuresBare,
features,
textCls,
hlCls,
hlStyle,
cls,
hasGraphics,
after,
plainCustom)

NodeProps(nType, isSlot, isSlotOrDescend, descend, isBaseNonSlot, isLexType, lexType, lineNumberFeature, featuresBare, features, textCls, hlCls, hlStyle, cls, hasGraphics, after, plainCustom)

Ancestors

  • builtins.tuple

Instance variables

var after

Whether 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

A 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

When calling T.text(n, descend=??) for this node, what should we substitute for the ?? ?

var features

Features to display in the labels of pretty displays with their names

var featuresBare

Features to display in the labels of pretty displays without their names

var hasGraphics

Whether this node type has graphics.

var hlCls

The highlight Css class of the current node, both for pretty and plain modes, keyed by boolean 'is pretty'

var hlStyle

The highlight Css color style of the current node, both for pretty and plain modes, keyed by boolean 'is pretty'

var isBaseNonSlot

Whether the current node has a type that is currently a baseType, i.e. a type where a pretty display should stop unfolding.

var isLexType

Whether nodes of type are lexemes.

var isSlot

Whether the current node is a slot node.

var isSlotOrDescend

Whether 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

If nodes of this type have lexemes in another type, this is that type.

var lineNumberFeature

Feature with source line numbers of nodes of this type.

var nType

The node type of the current node.

var plainCustom

Whether the app defines a custom method to plain displays for this node type.

var textCls

The text Css class of the current node.

class OuterSettings (slotType,
ltr,
fmt,
textClsDefault,
textMethod,
getText,
upMethod,
slotsMethod,
fLookupMethod,
eLookupMethod,
allEFeats,
browsing,
webLink,
getGraphics)

OuterSettings(slotType, ltr, fmt, textClsDefault, textMethod, getText, upMethod, slotsMethod, fLookupMethod, eLookupMethod, allEFeats, browsing, webLink, getGraphics)

Ancestors

  • builtins.tuple

Instance variables

var allEFeats

Set of all edge features: tf.core.api.Api.Eall(warp=False)

var browsing

whether we work for the TF browser or for a Jupyter notebook

var eLookupMethod

Method to get the value of an edge feature: Api.Es()

var fLookupMethod

Method to get the value of a node feature: Api.Fs()

var fmt

the currently selected text format.

var getGraphics

Method to fetch graphics for a node. App-dependent.See tf.advanced.settings under graphics.

var getText

Method to get the text for a node according to a template: getText()

var ltr

writing direction.

var slotType

The slot type of the dataset.

var slotsMethod

Method to get the slots of a node: OslotsFeature.s()

var textClsDefault

Default CSS class for full text.

var textMethod

Method to print text of a node according to a text format: Text.text()

var upMethod

Method to move from a node to its first embedder: Locality.u()

Method 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, and tf.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)