Package cjklib :: Package reading :: Module operator
[hide private]
[frames] | no frames]

Module operator

source code

Provides ReadingOperators, classes to handle strings written in a character reading.

Examples

Decompose a reading string in Gwoyeu Romatzyh into single entities:

>>> from cjklib.reading import ReadingFactory
>>> f = ReadingFactory()
>>> f.decompose('"Hannshyue" .de mingcheng duey Jonggwo [...]', 'GR')
['"', 'Hann', 'shyue', '" ', '.de', ' ', 'ming', 'cheng', ' ', 'duey',
' ', 'Jong', 'gwo', ' [...]']

The same can be done by directly using the operator's instance:

>>> from cjklib.reading import operator
>>> cy = operator.CantoneseYaleOperator()
>>> cy.decompose('gwóngjàuwá')
[u'gwóng', u'jàu', u'wá']

Composing will reverse the process, using a Pinyin string:

>>> f.compose([u'xī', u'ān'], 'Pinyin')
u"xī'ān"

For more complex operators, see PinyinOperator or MandarinIPAOperator.

Classes [hide private]
  ReadingOperator
Defines an abstract operator on text written in a character reading.
  RomanisationOperator
Defines an abstract ReadingOperator on text written in a romanisation, i.e.
  TonalFixedEntityOperator
Provides an abstract ReadingOperator for tonal languages for a reading based on a fixed set of reading entities.
  TonalRomanisationOperator
Provides an abstract RomanisationOperator for tonal languages incorporating methods from TonalFixedEntityOperator.
  TonalIPAOperator
Defines an operator on strings of a tonal language written in the International Phonetic Alphabet (IPA).
  SimpleEntityOperator
Provides an operator on readings with a single character per entity.
  HangulOperator
Provides an operator on Korean text written in Hangul.
  HiraganaOperator
Provides an operator on Japanese text written in Hiragana.
  KatakanaOperator
Provides an operator on Japanese text written in Katakana.
  KanaOperator
Provides an operator on Japanese text written in a mix of Hiragana and Katakana.
  PinyinOperator
Provides an operator for the Mandarin romanisation Hanyu Pinyin.
  WadeGilesOperator
Provides an operator for the Mandarin Wade-Giles romanisation.
  GROperator
Provides an operator for the Mandarin Gwoyeu Romatzyh romanisation.
  MandarinIPAOperator
Provides an operator on strings in Mandarin Chinese written in the International Phonetic Alphabet (IPA).
  MandarinBrailleOperator
Provides an operator on strings written in the Braille system.
  JyutpingOperator
Provides an operator for the Cantonese romanisation Jyutping made by the Linguistic Society of Hong Kong (LSHK).
  CantoneseYaleOperator
Provides an operator for the Cantonese Yale romanisation.
  CantoneseIPAOperator
Provides an operator on strings of the Cantonese language written in the International Phonetic Alphabet (IPA).