Package cjklib :: Module build :: Class CombinedStrokeCountBuilder :: Class CombinedStrokeCountGenerator
[hide private]
[frames] | no frames]

Class CombinedStrokeCountGenerator

source code

Generates the character stroke count mapping.

Instance Methods [hide private]
 
__init__(self, dbConnectInst, characterSet, tableEntries, preferredBuilder, quiet=False)
Initialises the CombinedStrokeCountGenerator.
source code
int
getStrokeCount(self, char, zVariant, strokeCountDict, unihanStrokeCountDict, decompositionDict)
Gets the stroke count of the given character by summing up the stroke count of its components and using the Unihan table as fallback.
source code
 
generator(self)
Provides one entry per character, z-Variant and locale subset.
source code
Method Details [hide private]

__init__(self, dbConnectInst, characterSet, tableEntries, preferredBuilder, quiet=False)
(Constructor)

source code 

Initialises the CombinedStrokeCountGenerator.

Parameters:
  • dbConnectInst (instance) - instance of a DatabaseConnector.
  • characterSet (set) - set of characters to generate the table for
  • tableEntries (list of list) - list of characters with Z-variant
  • preferredBuilder (instance) - TableBuilder which forms are preferred over entries from the Unihan table
  • quiet (bool) - if true no status information will be printed to stderr

getStrokeCount(self, char, zVariant, strokeCountDict, unihanStrokeCountDict, decompositionDict)

source code 

Gets the stroke count of the given character by summing up the stroke count of its components and using the Unihan table as fallback.

For the sake of consistency this method doesn't take the stroke count given by Unihan directly but sums up the stroke counts of the components to make sure the sum of component's stroke count will always give the characters stroke count. The result yielded will be in many cases even more precise than the value given in Unihan (not depending on the actual glyph form).

Once calculated the stroke count will be cached in the given strokeCountDict object.

Parameters:
  • char (str) - Chinese character
  • zVariant (int) - Z-variant of character
Returns: int
stroke count
Raises:
  • ValueError - if stroke count is ambiguous due to inconsistent values wrt Unihan vs. own data.
  • NoInformationError - if decomposition is incomplete