udapi.block.read.text module

Text class is a reader for word-wrapped plain-text files.

class udapi.block.read.text.Text(rstrip='\r\n ', **kwargs)[source]

Bases: BaseReader

A reader for plain-text files with sentences on one or more lines.

Sentences are separated by one or more empty lines. Newlines within sentences are substituted by a space.

Args: rstrip: a set of characters to be stripped from the end of each line.

Default=’rn ‘. You can use rstrip=’n’ if you want to preserve any space or ‘r’ (Carriage Return) at end of line, so that udpipe.Base keeps these characters in SpacesAfter. As most blocks do not expect whitespace other than a space to appear in the processed text, using this feature is at your own risk.

static is_multizone_reader()[source]

Can this reader read bundles which contain more zones?.

This implementation returns always False.

read_tree(document=None)[source]

Load one (more) tree from self.filehandle and return its root.

This method must be overriden in all readers. Usually it is the only method that needs to be implemented. The implementation in this base clases raises NotImplementedError.