Package jazzparser :: Package misc :: Package tree :: Module balancedseq :: Class BalancedSequence
[hide private]
[frames] | no frames]

Class BalancedSequence

source code

object --+
         |
        BalancedSequence

Elements should be just 0s and 1s.

Instance Methods [hide private]
 
__init__(self, sequence)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__getitem__(self, i) source code
 
__len__(self) source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
__add__(self, seq) source code
 
__eq__(self, other) source code
 
__hash__(self)
hash(x)
source code
 
check(self)
Checks that the balanced sequence is in fact balanced.
source code
 
balance(self, i)
Find the balanced subsequence beginning at i.
source code
 
head(self)
Pull the head out of the sequence
source code
 
head_tail(self)
Splits the sequence into its head and tail.
source code
 
decompose(self)
Returns a set containing the composition of the balanced sequence.
source code
 
_list_decompose(self)
Instead of doing all our operations on sets, do the recursive computation on lists and then convert to a set.
source code
 
to_tree(self)
Creates an unlabeled tree from the balanced sequence.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Static Methods [hide private]
 
cat(head, tail)
Produce a balanced sequence that is the result of taking head as the head and tail as the tail.
source code
 
from_tree(tree)
Converts an unlabeled tree representation to its equivalent balanced sequence.
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, sequence)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__hash__(self)
(Hashing function)

source code 

hash(x)

Overrides: object.__hash__
(inherited documentation)

check(self)

source code 

Checks that the balanced sequence is in fact balanced. For efficiency, this check is not carried out every time a sequence is created. You should make sure, therefore, to call this whenever you might generate an ill-formed sequence (e.g. when accepting input).

head_tail(self)

source code 

Splits the sequence into its head and tail. Since the head has to be computed in order to get the tail, it's best to do these at the same time and throw away the head if you don't need it.

cat(head, tail)
Static Method

source code 

Produce a balanced sequence that is the result of taking head as the head and tail as the tail. This is equivalent to:

 0<head>1<tail>

decompose(self)

source code 

Returns a set containing the composition of the balanced sequence. This is as defined in definition 4 of the paper, decomp(s).

from_tree(tree)
Static Method

source code 

Converts an unlabeled tree representation to its equivalent balanced sequence. If there are labels on the tree, they will just be ignored.