Package cjklib :: Package reading :: Module operator :: Class MandarinBrailleOperator
[hide private]
[frames] | no frames]

Class MandarinBrailleOperator

source code


Provides an operator on strings written in the Braille system.

Instance Methods [hide private]
 
__init__(self, **options)
Creates an instance of the MandarinBrailleOperator.
source code
set
getTones(self)
Returns a set of tones supported by the reading.
source code
list of str
decompose(self, string)
Decomposes the given string into basic entities that can be mapped to one Chinese character each (exceptions possible).
source code
str
compose(self, readingEntities)
Composes the given list of basic entities to a string.
source code
list of str
getSpaceSeparatedEntities(self, readingEntities)
Inserts spaces between to Braille entities for a given list of reading entities.
source code
str
getTonalEntity(self, plainEntity, tone)
Gets the entity with tone mark for the given plain entity and tone.
source code
tuple
splitEntityTone(self, entity)
Splits the entity into an entity without tone mark and the name of the entity's tone.
source code
bool
isReadingEntity(self, entity)
Returns true if the given entity is recognised by the reading operator, i.e.
source code
tuple of str
getOnsetRhyme(self, plainSyllable)
Splits the given plain syllable into onset (initial) and rhyme (final).
source code

Inherited from ReadingOperator: getOption

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Methods [hide private]

Inherited from ReadingOperator: getDefaultOptions

Class Variables [hide private]
  READING_NAME = 'MandarinBraille'
Unique name of reading
  TONEMARKS = [u'', u'', u'', u'', '']
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **options)
(Constructor)

source code 

Creates an instance of the MandarinBrailleOperator.

Parameters:
  • options - extra options
  • dbConnectInst - instance of a DatabaseConnector, if none is given, default settings will be assumed.
Overrides: object.__init__

getTones(self)

source code 

Returns a set of tones supported by the reading.

Returns: set
set of supported tone marks.

decompose(self, string)

source code 

Decomposes the given string into basic entities that can be mapped to one Chinese character each (exceptions possible).

The given input string can contain other non reading characters, e.g. punctuation marks.

The returned list contains a mix of basic reading entities and other characters e.g. spaces and punctuation marks.

Parameters:
  • string (str) - reading string
Returns: list of str
a list of basic entities of the input string
Raises:
Overrides: ReadingOperator.decompose

compose(self, readingEntities)

source code 

Composes the given list of basic entities to a string.

No special treatment is given for subsequent Braille entities. Use getSpaceSeparatedEntities() to insert spaces between two Braille syllables.

Parameters:
  • readingEntities (list of str) - list of basic entities or other content
Returns: str
composed entities
Overrides: ReadingOperator.compose

getSpaceSeparatedEntities(self, readingEntities)

source code 

Inserts spaces between to Braille entities for a given list of reading entities.

Spaces in the Braille system are applied between words. This is not reflected here and instead a space will be added between single syllables.

Parameters:
  • readingEntities (list of str) - list of basic entities or other content
Returns: list of str
entities with spaces inserted between Braille sequences

getTonalEntity(self, plainEntity, tone)

source code 

Gets the entity with tone mark for the given plain entity and tone.

Parameters:
  • plainEntity (str) - entity without tonal information
  • tone (str) - tone
Returns: str
entity with appropriate tone
Raises:

splitEntityTone(self, entity)

source code 

Splits the entity into an entity without tone mark and the name of the entity's tone.

Parameters:
  • entity (str) - entity with tonal information
Returns: tuple
plain entity without tone mark and additionally the tone
Raises:

isReadingEntity(self, entity)

source code 

Returns true if the given entity is recognised by the reading operator, i.e. it is a valid entity of the reading returned by decompose().

The default implementation will raise a NotImplementedError.

Parameters:
  • entity - entity to check
Returns: bool
true if string is an entity of the reading, false otherwise.
Overrides: ReadingOperator.isReadingEntity
(inherited documentation)

getOnsetRhyme(self, plainSyllable)

source code 

Splits the given plain syllable into onset (initial) and rhyme (final).

Parameters:
  • plainSyllable (str) - syllable without tone marks
Returns: tuple of str
tuple of syllable onset and rhyme
Raises: