Layer0

class ucca.layer0.Layer0(root, attrib=None)[source]

Bases: ucca.core.Layer

Represents the Terminal objects layer.

Attributes:
words: a tuple of only the words (not punctuation) Terminals, ordered pairs: a tuple of (position, terminal) tuples of all Terminals, ordered

Attributes Summary

pairs
words

Methods Summary

add_terminal(text, punct[, paragraph]) Adds the next Terminal at the next available position.
by_position(pos) Returns the Terminals at the position given.
copy(other_passage) Creates a copied Layer0 object and Terminals in other_passage.
doc(paragraph)
docs([num_paragraphs])

Attributes Documentation

pairs
words

Methods Documentation

add_terminal(text, punct, paragraph=1)[source]

Adds the next Terminal at the next available position.

Creates a Terminal object with the next position, assuming that all positions are filled (no holes).

Parameters:
  • text – the text of the Terminal
  • punct – boolean, whether it’s a punctuation mark
  • paragraph – paragraph number, defaults to 1
Returns:

the created Terminal

Raises:

DuplicateIdError – if trying to add an already existing Terminal, caused by un-ordered Terminal positions in the layer

by_position(pos)[source]

Returns the Terminals at the position given.

Parameters:pos – the position of the Terminal object
Returns:the Terminal in this position
Raises:IndexError – if the position is out of bounds
copy(other_passage)[source]

Creates a copied Layer0 object and Terminals in other_passage.

Parameters:other_passage – the Passage to copy self to
doc(paragraph)[source]
docs(num_paragraphs=1)[source]