Ejemplo n.º 1
0
        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]);
            }
        }
Ejemplo n.º 2
0
        /**
         * Add a pattern to the tree. Mainly, to be used by
         * {@link SimplePatternParser SimplePatternParser} 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);
        }
Ejemplo n.º 3
0
 /**
  * Add a character class to the tree. It is used by
  * {@link SimplePatternParser SimplePatternParser} 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);
         }
     }
 }