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)
Expand source code Browse git
class NodeProps:
    """Node properties during plain() or pretty().
    """

    pass

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
Expand source code Browse git
class NodeProps:
    """Node properties during plain() or pretty().
    """

    pass

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
Expand source code Browse git
class NodeProps:
    """Node properties during plain() or pretty().
    """

    pass

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
Expand source code Browse git
class NodeProps:
    """Node properties during plain() or pretty().
    """

    pass

When 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().
    """

    pass

Features 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().
    """

    pass

Features 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().
    """

    pass

Whether this node type has graphics.

var hlCls
Expand source code Browse git
class NodeProps:
    """Node properties during plain() or pretty().
    """

    pass

The 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().
    """

    pass

The 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().
    """

    pass

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
Expand source code Browse git
class NodeProps:
    """Node properties during plain() or pretty().
    """

    pass

Whether nodes of type are lexemes.

var isSlot
Expand source code Browse git
class NodeProps:
    """Node properties during plain() or pretty().
    """

    pass

Whether the current node is a slot node.

var isSlotOrDescend
Expand source code Browse git
class NodeProps:
    """Node properties during plain() or pretty().
    """

    pass

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
Expand source code Browse git
class NodeProps:
    """Node properties during plain() or pretty().
    """

    pass

If 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().
    """

    pass

Feature with source line numbers of nodes of this type.

var nType
Expand source code Browse git
class NodeProps:
    """Node properties during plain() or pretty().
    """

    pass

The node type of the current node.

var plainCustom
Expand source code Browse git
class NodeProps:
    """Node properties during plain() or pretty().
    """

    pass

Whether 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().
    """

    pass

The 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().
    """

    pass

OuterSettings(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().
    """

    pass

Set 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().
    """

    pass

whether 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().
    """

    pass

Method 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().
    """

    pass

Method 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().
    """

    pass

the currently selected text format.

var getGraphics
Expand source code Browse git
class OuterSettings:
    """Common properties during plain() and pretty().
    """

    pass

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

var getText
Expand source code Browse git
class OuterSettings:
    """Common properties during plain() and pretty().
    """

    pass

Method 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().
    """

    pass

writing direction.

var slotType
Expand source code Browse git
class OuterSettings:
    """Common properties during plain() and pretty().
    """

    pass

The slot type of the dataset.

var slotsMethod
Expand source code Browse git
class OuterSettings:
    """Common properties during plain() and pretty().
    """

    pass

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

var textClsDefault
Expand source code Browse git
class OuterSettings:
    """Common properties during plain() and pretty().
    """

    pass

Default CSS class for full text.

var textMethod
Expand source code Browse git
class OuterSettings:
    """Common properties during plain() and pretty().
    """

    pass

Method 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().
    """

    pass

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

Expand source code Browse git
class OuterSettings:
    """Common properties during plain() and pretty().
    """

    pass

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)