Module dopg
[hide private]
[frames] | no frames]

Module dopg

source code

DOP1 implementation. Andreas van Cranenburgh <andreas@unstable.nl> TODOs: unicode support (replace str and repr calls)

Classes [hide private]
  GoodmanDOP
Functions [hide private]
 
cartprod(a, b)
cartesian product of two sequences
source code
 
cartpi(seq)
produce a flattened fold using cartesian product as operator
source code
list of Productions
productions(tree)
Generate the productions that correspond to the non-terminal nodes of the tree.
source code
 
main()
a basic REPL for testing
source code
Variables [hide private]
  __package__ = None
Function Details [hide private]

cartpi(seq)

source code 

produce a flattened fold using cartesian product as operator

>>> list(cartpi( ( (1,2), (3,4), (5,6) ) ) )
[(1, 3, 5), (2, 3, 5), (1, 4, 5), (2, 4, 5), (1, 3, 6), (2, 3, 6), 
(1, 4, 6), (2, 4, 6)]

productions(tree)

source code 

Generate the productions that correspond to the non-terminal nodes of the tree. For each subtree of the form (P: C1 C2 ... Cn) this produces a production of the form P -> C1 C2 ... Cn.

Returns: list of Productions