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

Class JyutpingYaleConverter

source code


Provides a converter between the Cantonese romanisation systems Jyutping and Cantonese Yale.

Upper or lower case will be transfered between syllables, no special formatting according to the standards will be made. Upper/lower case will be identified according to three classes: either the whole syllable is upper case, only the initial letter is upper case or otherwise the whole syllable is assumed being lower case.

High Level vs. High Falling Tone

As described in CantoneseYaleOperator the Cantonese Yale romanisation system makes a distinction between the high level tone and the high falling tone in general while Jyutping does not. On conversion it is thus important to choose the correct mapping. This can be configured by applying a special instance of a CantoneseYaleOperator.

Instance Methods [hide private]
 
__init__(self, *args, **options)
Creates an instance of the JyutpingYaleConverter.
source code
str
convertBasicEntity(self, entity, fromReading, toReading)
Converts a basic entity (e.g.
source code

Inherited from RomanisationConverter: convertEntities

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_DIRECTIONS = [('Jyutping', 'CantoneseYale'), ('Cant...
List of tuples for specifying supported conversion directions from reading A to reading B.
  DEFAULT_READING_OPTIONS = {'CantoneseYale': {'toneMarkType': '...
Defines default reading options for the reading used to convert from (to resp.) before (after resp.) converting to (from resp.) the user specified dialect.
  DEFAULT_TONE_MAPPING = {2: '2ndTone', 3: '3rdTone', 4: '4thTon...
Mapping of Jyutping tones to Yale tones.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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

source code 

Creates an instance of the JyutpingYaleConverter.

Parameters:
  • args - optional list of RomanisationOperators to use for handling source and target readings.
  • options - extra options
  • dbConnectInst - instance of a DatabaseConnector, if none is given, default settings will be assumed.
  • sourceOperators - list of ReadingOperators used for handling source readings.
  • targetOperators - list of ReadingOperators used for handling target readings.
Overrides: object.__init__

convertBasicEntity(self, entity, fromReading, toReading)

source code 

Converts a basic entity (e.g. a syllable) in the source reading to the given target reading.

This method is called by convertEntities() and a lower case entity is given for conversion. The returned value should be in lower case characters too, as convertEntities() will take care of capitalisation.

If a single entity needs to be converted it is recommended to use convertEntities() instead. In the general case it can not be ensured that a mapping from one reading to another can be done by the simple conversion of a basic entity. One-to-many mappings are possible and there is no guarantee that any entity of a reading recognised by operator.ReadingOperator.isReadingEntity() will be mapped here.

The default implementation will raise a NotImplementedError.

Parameters:
  • entity - string written in the source reading in lower case letters
  • fromReading - name of the source reading
  • toReading - name of the target reading
Returns: str
the entity converted to the toReading in lower case
Raises:
Overrides: EntityWiseReadingConverter.convertBasicEntity
(inherited documentation)

Class Variable Details [hide private]

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:
[('Jyutping', 'CantoneseYale'), ('CantoneseYale', 'Jyutping')]

DEFAULT_READING_OPTIONS

Defines default reading options for the reading used to convert from (to resp.) before (after resp.) converting to (from resp.) the user specified dialect.

The most general reading dialect should be specified as to allow for a broad range of input.

Value:
{'CantoneseYale': {'toneMarkType': 'Internal'}, 'Jyutping': {}}

DEFAULT_TONE_MAPPING

Mapping of Jyutping tones to Yale tones. Tone 1 needs to be handled independently.

Value:
{2: '2ndTone', 3: '3rdTone', 4: '4thTone', 5: '5thTone', 6: '6thTone'}