Package cjklib :: Package reading :: Module converter :: Class BridgeConverter
[hide private]
[frames] | no frames]

Class BridgeConverter

source code


Provides a ReadingConverter that converts between readings over a third reading called bridge reading.

Instance Methods [hide private]
list of tuple
_getConversionDirections(bridge)
Extracts all conversion directions implicitly stored in the bridge definition.
source code
 
__init__(self, *args, **options)
Creates an instance of the BridgeConverter.
source code
list of str
convertEntities(self, readingEntities, fromReading, toReading)
Converts a list of entities in the source reading to the given target reading.
source code

Inherited from ReadingConverter: convert, getOption

Inherited from ReadingConverter (private): _getFromOperator, _getToOperator

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

Class Methods [hide private]

Inherited from ReadingConverter: getDefaultOptions

Class Variables [hide private]
  CONVERSION_BRIDGE = [('WadeGiles', 'Pinyin', 'MandarinIPA'), (...
List containing all conversion directions together with the bridge reading over which the conversion is made.
  CONVERSION_DIRECTIONS = [('WadeGiles', 'GR'), ('GR', 'WadeGile...
List of tuples for specifying supported conversion directions from reading A to reading B.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_getConversionDirections(bridge)

source code 

Extracts all conversion directions implicitly stored in the bridge definition.

Parameters:
  • bridge (list of tuple) - 3-tuples indicating conversion direction over a third reading (bridge)
Returns: list of tuple
conversion directions

__init__(self, *args, **options)
(Constructor)

source code 

Creates an instance of the BridgeConverter.

Parameters:
Overrides: object.__init__

convertEntities(self, readingEntities, fromReading, toReading)

source code 

Converts a list of entities in the source reading to the given target reading.

The default implementation will raise a NotImplementedError.

Parameters:
  • readingEntities - list of entities written in source reading
  • fromReading - name of the source reading
  • toReading - name of the target reading
Returns: list of str
list of entities written in target reading
Raises:
  • ConversionError - on operations specific to the conversion between the two readings (e.g. error on converting entities).
  • UnsupportedError - if source or target reading is not supported for conversion.
  • InvalidEntityError - if an invalid entity is given.
Overrides: ReadingConverter.convertEntities
(inherited documentation)

Class Variable Details [hide private]

CONVERSION_BRIDGE

List containing all conversion directions together with the bridge reading over which the conversion is made. Form: (fromReading, bridgeReading, toReading) As conversion may be lossy it is important which conversion path is chosen.

Value:
[('WadeGiles', 'Pinyin', 'MandarinIPA'),
 ('MandarinBraille', 'Pinyin', 'MandarinIPA'),
 ('WadeGiles', 'Pinyin', 'MandarinBraille'),
 ('MandarinBraille', 'Pinyin', 'WadeGiles'),
 ('GR', 'Pinyin', 'WadeGiles'),
 ('MandarinBraille', 'Pinyin', 'GR'),
 ('WadeGiles', 'Pinyin', 'GR'),
 ('GR', 'Pinyin', 'MandarinBraille'),
...

CONVERSION_DIRECTIONS

List of tuples for specifying supported conversion directions from reading A to reading B. If both directions are supported, two tuples (A, B) and (B, A) are given.

Value:
[('WadeGiles', 'GR'),
 ('GR', 'WadeGiles'),
 ('MandarinBraille', 'WadeGiles'),
 ('GR', 'MandarinBraille'),
 ('WadeGiles', 'MandarinBraille'),
 ('MandarinBraille', 'MandarinIPA'),
 ('WadeGiles', 'MandarinIPA'),
 ('GR', 'MandarinIPA'),
...