Class RomanisationConverter
source code
Defines an abstract ReadingConverter between two or more
romanisations.
Reading dialects can produce different entities which have to be
handled by the conversion process. This is realised by converting the
given reading dialect to a default form, then converting to the default
target reading and finally converting to the specified target reading
dialect. On conversion step thus involves three single conversion steps
using a default form. This default form can be defined in DEFAULT_READING_OPTIONS.
Upper or lower case will be transfered between syllables, no special
formatting according to anyhow defined standards will be guaranteed.
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.
The class itself can't be used directly, it has to be subclassed and
convertBasicEntity() has to be implemented, as to make
the translation of a syllable from one romanisation to another
possible.
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__
|
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 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
|
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 (str) - string written in the source reading in lower case letters
fromReading (str) - name of the source reading
toReading (str) - name of the target reading
- Returns: str
- the entity converted to the
toReading in lower case
- Raises:
- Overrides:
EntityWiseReadingConverter.convertBasicEntity
|
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:
-
|