Class PinyinWadeGilesConverter
source code
Provides a converter between the Chinese romanisation Hanyu
Pinyin and Wade-Giles.
Currently only a non standard subset of Wade-Giles is implemented. As
many different interpretations exist providing a complete coverage seems
hardly achievable. An important step is support for the revised system by
Giles as found in his Chinese-English Dictionary (as of 1912). A
further target is to at least implement means to support concrete shapes
found in the usage of big bodies e.g. libraries.
Upper or lower case will be transfered between syllables, no special
formatting according to the standards (i.e. Pinyin) 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.
Conversion cannot in general be done in a one-to-one manner. Standard
Pinyin has no notion to explicitly specify missing tonal information
while this is in general given in Wade-Giles by just omitting the tone
digits. This implementation furthermore doesn't support explicit
depiction of Erhua in the Wade-Giles romanisation system thus
failing when r-colourised syllables are found.
To Do (Lang):
Increase support for different reading dialects of the
Wade-Giles romanisation system. Includes support in WadeGilesOperator. Get proper sources on the syllables
and mappings. Use well-known instances.
Warning:
This module isn't backed-up by any sources yet and doesn't
guarantee a syllable mapping free of errors.
list of str
|
convertEntities(self,
readingEntities,
fromReading,
toReading)
Converts a list of entities in the source reading to the given target
reading. |
source code
|
|
str
|
|
Inherited from ReadingConverter :
__init__ ,
convert ,
getOption
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__str__
|
|
CONVERSION_DIRECTIONS = [ ( ' Pinyin ' , ' WadeGiles ' ) , ( ' WadeGiles ' ...
List of tuples for specifying supported conversion directions from
reading A to reading B.
|
|
DEFAULT_READING_OPTIONS = { ' Pinyin ' : { ' Erhua ' : ' ignore ' , ' tone ...
Defines default reading options for the reading used to convert from
(to resp.) before (after resp.) converting to (from resp.) the user
specified dialect.
|
Inherited from object :
__class__
|
convertEntities(self,
readingEntities,
fromReading,
toReading)
| source code
|
Converts a list of entities in the source reading to the given target
reading.
Upper case of the first character or the whole characters of one
entity (e.g. syllable) is respected. Entities like
"HaO" will degenerate to
"Hao" though.
- 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:
- Overrides:
ReadingConverter.convertEntities
- (inherited documentation)
|
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)
|
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:
[ ( ' Pinyin ' , ' WadeGiles ' ) , ( ' WadeGiles ' , ' Pinyin ' ) ]
|
|
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:
{ ' Pinyin ' : { ' Erhua ' : ' ignore ' , ' toneMarkType ' : ' Numbers ' } ,
' WadeGiles ' : { } }
|
|