Package cjklib :: Package reading :: Class ReadingFactory :: Class SimpleReadingConverterAdaptor
[hide private]
[frames] | no frames]

Class SimpleReadingConverterAdaptor

source code


Defines a simple converter between two character readings that keeps the real converter doing the work in the background.

The basic method is convert() which converts one input string from one reading to another. In contrast to a ReadingConverter no source or target reading needs to be specified.

Instance Methods [hide private]
 
__init__(self, converterInst, fromReading, toReading)
Creates an instance of the SimpleReadingConverterAdaptor.
source code
str
convert(self, string, fromReading=None, toReading=None)
Converts a string in the source reading to the target reading.
source code
list of str
convertEntities(self, readingEntities, fromReading=None, toReading=None)
Converts a list of entities in the source reading to the target reading.
source code
 
__getattr__(self, name) source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, converterInst, fromReading, toReading)
(Constructor)

source code 

Creates an instance of the SimpleReadingConverterAdaptor.

Parameters:
  • converterInst (instance) - ReadingConverter instance doing the actual conversion work.
  • fromReading (str) - name of reading converted from
  • toReading (str) - name of reading converted to
Overrides: object.__init__

convert(self, string, fromReading=None, toReading=None)

source code 

Converts a string in the source reading to the target reading.

If parameters fromReading or toReading are not given the class's default values will be applied.

Parameters:
  • string (str) - string written in the source reading
  • fromReading (str) - name of the source reading
  • toReading (str) - name of the target reading
Returns: str
the input string converted to the toReading
Raises:
  • DecompositionError - if the string can not be decomposed into basic entities with regards to the source reading.
  • ConversionError - on operations specific to the conversion between the two readings (e.g. error on converting entities).
  • UnsupportedError - if source or target reading not supported for conversion.

convertEntities(self, readingEntities, fromReading=None, toReading=None)

source code 

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

If parameters fromReading or toReading are not given the class's default values will be applied.

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:
  • 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.