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

Class PinyinDialectConverter

source code


Provides a converter for different representations of the Chinese romanisation Hanyu Pinyin.

Examples

The following examples show how to convert between different representations of Pinyin.

Instance Methods [hide private]
 
__init__(self, *args, **options)
Creates an instance of the PinyinDialectConverter.
source code
list of str
convertEntities(self, readingEntities, fromReading='Pinyin', toReading='Pinyin')
Converts a list of entities in the source reading to the given target reading.
source code
list of tuple/str
convertToSingleSyllableErhua(self, entityTuples)
Converts the various Erhua forms in a list of reading entities to a representation with one syllable, e.g.
source code
list of tuple/str
convertToTwoSyllablesErhua(self, entityTuples)
Converts the various Erhua forms in a list of reading entities to a representation with two syllable, e.g.
source code
list of tuple/str
_checkForErhua(self, entityTuples)
Checks the given entities for Erhua forms and raises a ConversionError.
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]
dict
getDefaultOptions(cls)
Returns the reading converter's default options.
source code
Class Variables [hide private]
  CONVERSION_DIRECTIONS = [('Pinyin', 'Pinyin')]
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]

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

source code 

Creates an instance of the PinyinDialectConverter.

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.
  • keepPinyinApostrophes - if set to True apostrophes separating two syllables in Pinyin will be kept even if not necessary. Apostrophes missing according to the given rule will be added though.
  • breakUpErhua - if set to 'on' Erhua forms will be converted to single syllables with a full er syllable regardless of the Erhua form setting of the target reading, e.g. zher will be converted to zhe, er, if set to 'auto' Erhua forms are converted if the given target reading operator doesn't support Erhua forms, if set to 'off' Erhua forms will always be conserved.
Overrides: object.__init__

getDefaultOptions(cls)
Class Method

source code 

Returns the reading converter's default options.

The keyword 'dbConnectInst' is not regarded a configuration option of the converter and is thus not included in the dict returned.

Returns: dict
the reading converter's default options.
Overrides: ReadingConverter.getDefaultOptions
(inherited documentation)

convertEntities(self, readingEntities, fromReading='Pinyin', toReading='Pinyin')

source code 

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

Parameters:
  • readingEntities (list of str) - list of entities written in source reading
  • fromReading (str) - name of the source reading
  • toReading (str) - name of the target reading
Returns: list of str
list of entities written in target reading
Raises:
Overrides: ReadingConverter.convertEntities

convertToSingleSyllableErhua(self, entityTuples)

source code 

Converts the various Erhua forms in a list of reading entities to a representation with one syllable, e.g. ['tou2', 'r5'] to ['tour2'].

Parameters:
  • entityTuples (list of tuple/str) - list of tuples with plain syllable and tone
Returns: list of tuple/str
list of tuples with plain syllable and tone

convertToTwoSyllablesErhua(self, entityTuples)

source code 

Converts the various Erhua forms in a list of reading entities to a representation with two syllable, e.g. ['tour2'] to ['tou2', 'r5'].

Parameters:
  • entityTuples (list of tuple/str) - list of tuples with plain syllable and tone
Returns: list of tuple/str
list of tuples with plain syllable and tone

_checkForErhua(self, entityTuples)

source code 

Checks the given entities for Erhua forms and raises a ConversionError.

Parameters:
  • entityTuples (list of tuple/str) - list of tuples with plain syllable and tone
Returns: list of tuple/str
list of tuples with plain syllable and tone
Raises: