Package cjklib :: Module build :: Class CharacterResidualStrokeCountBuilder :: Class ResidualStrokeCountExtractor
[hide private]
[frames] | no frames]

Class ResidualStrokeCountExtractor

source code

Generates the character to residual stroke count mapping from the CharacterRadicalResidualStrokeCount table.

Instance Methods [hide private]
 
__init__(self, dbConnectInst, characterSet)
Initialises the ResidualStrokeCountExtractor.
source code
list of tuple
getEntries(self, char, zVariant, radicalDict)
Gets a list of radical residual entries.
source code
 
generator(self)
Provides one entry per character, z-Variant and locale subset.
source code
Method Details [hide private]

__init__(self, dbConnectInst, characterSet)
(Constructor)

source code 

Initialises the ResidualStrokeCountExtractor.

Parameters:
  • dbConnectInst (instance) - instance of a DatabaseConnector
  • characterSet (set) - set of characters to generate the table for

getEntries(self, char, zVariant, radicalDict)

source code 

Gets a list of radical residual entries. For multiple radical occurrences (e.g. 伦) only returns the residual stroke count for the "main" radical form.

Parameters:
  • char (str) - Chinese character
  • zVariant (int) - Z-variant of given character
Returns: list of tuple
list of residual stroke count entries

To Do (Lang): Implement, find a good algorithm to turn down unwanted forms, don't just choose random one. See the following list:


>>> from cjklib import characterlookup
>>> cjk = characterlookup.CharacterLookup()
>>> for char in cjk.db.selectSoleValue('CharacterRadicalResidualStrokeCount',
...     'ChineseCharacter', distinctValues=True):
...     try:
...         entries = cjk.getCharacterKangxiRadicalResidualStrokeCount(char, 'C')
...         lastEntry = entries[0]
...         for entry in entries[1:]:
...             # print if diff. radical forms and diff. residual stroke count
...             if lastEntry[0] != entry[0] and lastEntry[2] != entry[2]:
...                 print char
...                 break
...             lastEntry = entry
...     except:
...         pass
...





>>> cjk.getCharacterKangxiRadicalResidualStrokeCount(u'缧')
[(u'糸', 0, u'⿻', 0, 8), (u'纟', 0, u'⿰', 0, 11)]