Package nltk_lite :: Package draw :: Module cfg'
[hide private]
[frames] | no frames]

Module cfg'

source code

Visualization tools for CFGs.

Classes [hide private]
  AbstractContainerWidget
An abstract class for canvas widgets that contain a single child, such as BoxWidget and OvalWidget.
  AbstractParse
An abstract base class for parsers.
  BaseWidget
Internal class.
  BitmapImage
Widget which can display a bitmap.
  BooleanType
bool(x) -> bool
  BooleanVar
Value holder for boolean variables.
  BoxWidget
A canvas widget that places a box around a child widget.
  BracketWidget
A canvas widget that places a pair of brackets around a child widget.
  BufferType
buffer(object [, offset[, size]])
  BuiltinFunctionType
  BuiltinMethodType
  Button
Button widget.
  CFGDemo
  CFGEditor
A dialog window for creating and editing context free grammars.
  CallWrapper
Internal class.
  Canvas
Canvas widget to display graphical elements like lines or text.
  CanvasFrame
A Tkinter frame containing a canvas and scrollbars.
  CanvasWidget
A collection of graphical elements and bindings used to display a complex object on a Tkinter Canvas.
  Checkbutton
Checkbutton widget which is either in on- or off-state.
  ClassType
classobj(name, bases, dict)
  CodeType
code(argcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab[, freevars[, cellvars]])
  ColorizedList
An abstract base class for displaying a colorized list of items.
  ComplexType
complex(real[, imag]) -> complex number
  DictProxyType
  DictType
dict() -> new empty dictionary.
  DictionaryType
dict() -> new empty dictionary.
  DoubleVar
Value holder for float variables.
  EllipsisType
  Entry
Entry widget which allows to display simple text.
  EntryDialog
A dialog box for entering
  Event
Container for the properties of an event.
  FileType
file(name[, mode[, buffering]]) -> file object
  FloatType
float(x) -> floating point number
  Frame
Frame widget which may contain other widgets and can have a 3D border.
  FrameType
  FunctionType
function(code, globals[, name[, argdefs[, closure]]])
  GeneratorType
  GetSetDescriptorType
  Grammar
A context-free grammar.
  Grid
Geometry manager Grid.
  Image
Base class for images.
  ImmutableProbabilisticTree
  ImmutableTree
  InstanceType
instance(class[, dict])
  IntType
int(x[, base]) -> integer
  IntVar
Value holder for integer variables.
  Label
Label widget which can display text and bitmaps.
  LabelFrame
labelframe widget.
  LambdaType
function(code, globals[, name[, argdefs[, closure]]])
  ListType
list() -> new list list(sequence) -> new list initialized from sequence's items
  Listbox
Listbox widget which can display a list of strings.
  LongType
long(x[, base]) -> integer
  MemberDescriptorType
  Menu
Menu widget which allows to display menu bars, pull-down menus and pop-up menus.
  Menubutton
Menubutton widget, obsolete since Tk8.0.
  Message
Message widget to display multiline text.
  MethodType
instancemethod(function, instance, class)
  Misc
Internal class.
  ModuleType
module(name[, doc])
  MutableOptionMenu
  NoneType
  Nonterminal
A non-terminal symbol for a context free grammar.
  NotImplementedType
  ObjectType
The most base type
  OptionMenu
OptionMenu which allows the user to select a value from a menu.
  OvalWidget
A canvas widget that places a oval around a child widget.
  Pack
Geometry manager Pack.
  PanedWindow
panedwindow widget.
  ParenWidget
A canvas widget that places a pair of parenthases around a child widget.
  ParseI
A processing class for deriving trees that represent possible structures for a sequence of tokens.
  PhotoImage
Widget which can display colored images in GIF, PPM/PGM format.
  Place
Geometry manager Place.
  ProbabilisticMixIn
A mix-in class to associate probabilities with other classes (trees, rules, etc.).
  ProbabilisticTree
  Production
A context-free grammar production.
  ProductionList
  Radiobutton
Radiobutton widget which shows only one of several buttons in on-state.
  Scale
Scale widget which can display a numerical scale.
  ScrollWatcherWidget
A special canvas widget that adjusts its Canvas's scrollregion to always include the bounding boxes of all of its children.
  Scrollbar
Scrollbar widget which displays a slider at a certain position.
  SequenceWidget
A canvas widget that keeps a list of canvas widgets in a horizontal line.
  ShowText
A Tkinter window used to display a text.
  SliceType
slice([start,] stop[, step])
  SpaceWidget
A canvas widget that takes up space but does not display anything.
  Spinbox
spinbox widget.
  StackWidget
A canvas widget that keeps a list of canvas widgets in a vertical line.
  StringType
str(object) -> string
  StringVar
Value holder for strings variables.
  Studbutton
  SymbolWidget
A canvas widget that displays special symbols, such as the negation sign and the exists operator.
  TclError
  Text
Text widget which can display text in various forms.
  TextWidget
A canvas widget that displays a single string of text.
  Tk
Toplevel widget of Tk which represents mostly the main window of an appliation.
  Toplevel
Toplevel widget, e.g.
  TracebackType
  Tree
A hierarchical structure.
  TreeSegmentWidget
A canvas widget that displays a single segment of a hierarchical tree.
  TreeView
  TreeWidget
A canvas widget that displays a single Tree.
  Tributton
  TupleType
tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items
  TypeType
type(object) -> the object's type type(name, bases, dict) -> a new type
  UnboundMethodType
instancemethod(function, instance, class)
  UnicodeType
unicode(string [, encoding[, errors]]) -> object
  Variable
Class to define value holders for e.g.
  Widget
Internal class.
  Wm
Provides functions for the communication with the window manager.
  XRangeType
xrange([start,] stop[, step]) -> xrange object
  getdouble
float(x) -> floating point number
  getint
int(x[, base]) -> integer
Functions [hide private]
 
At(x, y=None)
 
AtEnd()
 
AtInsert(*args)
 
AtSelFirst()
 
AtSelLast()
 
NoDefaultRoot()
Inhibit setting of default root window.
 
Tcl(screenName=None, baseName=None, className='Tk', useTk=0)
tree
bracket_parse(s)
Parse a treebank string and return a tree.
source code
 
demo() source code
 
demo2() source code
 
demo3() source code
None
draw_trees(*trees)
Open a new window containing a graphical diagram of the given trees.
source code
 
getboolean(s)
Convert true and false to integer values 1 and 0.
 
image_names()
 
image_types()
boolean
in_idle()
Returns: true if this function is run within idle.
source code
 
mainloop(n=0)
Run the main loop of Tcl.
list of Nonterminal
nonterminals(symbols)
Given a string containing a list of symbol names, return a list of Nonterminals constructed from those symbols.
source code
 
parse_cfg(s) source code
 
parse_cfg_production(s)
Returns a list of productions
source code
tree
sinica_parse(s)
Parse a Sinica Treebank string and return a tree.
source code
 
tree_to_treesegment(canvas, t, make_node=<class 'nltk_lite.draw.TextWidget'>, make_leaf=<class 'nltk_lite.draw.TextWidget'>, **attribs)
Convert a Tree into a TreeSegmentWidget.
source code
Variables [hide private]
  ACTIVE = 'active'
  ALL = 'all'
  ANCHOR = 'anchor'
  ARC = 'arc'
  BASELINE = 'baseline'
  BEVEL = 'bevel'
  BOTH = 'both'
  BOTTOM = 'bottom'
  BROWSE = 'browse'
  BUTT = 'butt'
  CASCADE = 'cascade'
  CENTER = 'center'
  CHAR = 'char'
  CHECKBUTTON = 'checkbutton'
  CHORD = 'chord'
  COMMAND = 'command'
  CURRENT = 'current'
  DISABLED = 'disabled'
  DOTBOX = 'dotbox'
  E = 'e'
  END = 'end'
  EW = 'ew'
  EXCEPTION = 8
  EXTENDED = 'extended'
  FALSE = 0
  FIRST = 'first'
  FLAT = 'flat'
  GROOVE = 'groove'
  HIDDEN = 'hidden'
  HORIZONTAL = 'horizontal'
  INSERT = 'insert'
  INSIDE = 'inside'
  LAST = 'last'
  LEFT = 'left'
  MITER = 'miter'
  MOVETO = 'moveto'
  MULTIPLE = 'multiple'
  N = 'n'
  NE = 'ne'
  NO = 0
  NONE = 'none'
  NORMAL = 'normal'
  NS = 'ns'
  NSEW = 'nsew'
  NUMERIC = 'numeric'
  NW = 'nw'
  OFF = 0
  ON = 1
  OUTSIDE = 'outside'
  PAGES = 'pages'
  PIESLICE = 'pieslice'
  PROJECTING = 'projecting'
  RADIOBUTTON = 'radiobutton'
  RAISED = 'raised'
  READABLE = 2
  RIDGE = 'ridge'
  RIGHT = 'right'
  ROUND = 'round'
  S = 's'
  SCROLL = 'scroll'
  SE = 'se'
  SEL = 'sel'
  SEL_FIRST = 'sel.first'
  SEL_LAST = 'sel.last'
  SEPARATOR = 'separator'
  SINGLE = 'single'
  SOLID = 'solid'
  SUNKEN = 'sunken'
  SW = 'sw'
  StringTypes = (<type 'str'>, <type 'unicode'>)
  TOP = 'top'
  TRUE = 1
  TclVersion = 8.4
  TkVersion = 8.4
  UNDERLINE = 'underline'
  UNITS = 'units'
  VERTICAL = 'vertical'
  W = 'w'
  WORD = 'word'
  WRITABLE = 4
  X = 'x'
  Y = 'y'
  YES = 1
  _CFGEditor_HELP = '\n\nThe CFG Editor can be used to create or...
  wantobjects = 1
Function Details [hide private]

NoDefaultRoot()

 

Inhibit setting of default root window.

Call this function to inhibit that the first instance of Tk is used for windows without an explicit parent window.

bracket_parse(s)

source code 

Parse a treebank string and return a tree. Trees are represented as nested brackettings, e.g. (S (NP (NNP John)) (VP (V runs))).

Parameters:
  • s (string) - The string to be converted
Returns: tree
A tree corresponding to the string representation.

in_idle()

source code 
Returns: boolean
true if this function is run within idle. Tkinter programs that are run in idle should never call Tk.mainloop; so this function should be used to gate all calls to Tk.mainloop.

Warning: This function works by checking sys.stdin. If the user has modified sys.stdin, then it may return incorrect results.

nonterminals(symbols)

source code 

Given a string containing a list of symbol names, return a list of Nonterminals constructed from those symbols.

Parameters:
  • symbols (string) - The symbol name string. This string can be delimited by either spaces or commas.
Returns: list of Nonterminal
A list of Nonterminals constructed from the symbol names given in symbols. The Nonterminals are sorted in the same order as the symbols names.

sinica_parse(s)

source code 

Parse a Sinica Treebank string and return a tree. Trees are represented as nested brackettings, as shown in the following example (X represents a Chinese character): S(goal:NP(Head:Nep:XX)|theme:NP(Head:Nhaa:X)|quantity:Dab:X|Head:VL2:X)#0(PERIODCATEGORY)

Parameters:
  • s (string) - The string to be converted
Returns: tree
A tree corresponding to the string representation.

tree_to_treesegment(canvas, t, make_node=<class 'nltk_lite.draw.TextWidget'>, make_leaf=<class 'nltk_lite.draw.TextWidget'>, **attribs)

source code 

Convert a Tree into a TreeSegmentWidget.

Parameters:
  • make_node - A CanvasWidget constructor or a function that creates CanvasWidgets. make_node is used to convert the Tree's nodes into CanvasWidgets. If no constructor is specified, then TextWidget will be used.
  • make_leaf - A CanvasWidget constructor or a function that creates CanvasWidgets. make_leaf is used to convert the Tree's leafs into CanvasWidgets. If no constructor is specified, then TextWidget will be used.
  • attribs - Attributes for the canvas widgets that make up the returned TreeSegmentWidget. Any attribute beginning with 'tree_' will be passed to all TreeSegmentWidgets (with the 'tree_' prefix removed. Any attribute beginning with 'node_' will be passed to all nodes. Any attribute beginning with 'leaf_' will be passed to all leaves. And any attribute beginning with 'loc_' will be passed to all text locations (for Trees).

Variables Details [hide private]

_CFGEditor_HELP

Value:
'''

The CFG Editor can be used to create or modify context free grammars.
A context free grammar consists of a start symbol and a list of
productions.  The start symbol is specified by the text entry field in
the upper right hand corner of the editor; and the list of productions
are specified in the main text editing box.

...