private void compact(CharVector kx, TernaryTree map, char p) { int k; if (p == 0) { return; } if (sc[p] == 0xFFFF) { k = map.find(kv.Arr, lo[p]); if (k < 0) { k = kx.alloc(strlen(kv.Arr, lo[p]) + 1); strcpy(kx.Arr, k, kv.Arr, lo[p]); map.insert(kx.Arr, k, (char)k); } lo[p] = (char)k; } else { compact(kx, map, lo[p]); if (sc[p] != 0) { compact(kx, map, eq[p]); } compact(kx, map, hi[p]); } }
/** * Add a pattern to the tree. Mainly, to be used by * PatternParser class as callback to * add a pattern to the tree. * @param pattern the hyphenation pattern * @param ivalue interletter weight values indicating the * desirability and priority of hyphenating at a given point * within the pattern. It should contain only digit characters. * (i.e. '0' to '9'). */ public void addPattern(string pattern, string ivalue) { int k = ivalues.find(ivalue); if (k <= 0) { k = packValues(ivalue); ivalues.insert(ivalue, (char)k); } insert(pattern, (char)k); }
/** * Add a character class to the tree. It is used by * PatternParser as callback to * add character classes. Character classes define the * valid word characters for hyphenation. If a word contains * a character not defined in any of the classes, it is not hyphenated. * It also defines a way to normalize the characters in order * to compare them with the stored patterns. Usually pattern * files use only lower case characters, in this case a class * for letter 'a', for example, should be defined as "aA", the first * character being the normalization char. */ public void addClass(string chargroup) { if (chargroup.Length > 0) { char equivChar = chargroup[0]; char[] key = new char[2]; key[1] = (char)0; for (int i = 0; i < chargroup.Length; i++) { key[0] = chargroup[i]; classmap.insert(key, 0, equivChar); } } }