Example #1
0
        private void Compact(CharVector kx, TernaryTree map, char p)
        {
            int k;

            if (p == 0)
            {
                return;
            }
            if (m_sc[p] == 0xFFFF)
            {
                k = map.Find(m_kv.Array, m_lo[p]);
                if (k < 0)
                {
                    k = kx.Alloc(StrLen(m_kv.Array, m_lo[p]) + 1);
                    StrCpy(kx.Array, k, m_kv.Array, m_lo[p]);
                    map.Insert(kx.Array, k, (char)k);
                }
                m_lo[p] = (char)k;
            }
            else
            {
                Compact(kx, map, m_lo[p]);
                if (m_sc[p] != 0)
                {
                    Compact(kx, map, m_eq[p]);
                }
                Compact(kx, map, m_hi[p]);
            }
        }
Example #2
0
        /// <summary>
        /// Add a pattern to the tree. Mainly, to be used by
        /// <see cref="PatternParser"/> class as callback to add a pattern to
        /// the tree.
        /// </summary>
        /// <param name="pattern"> the hyphenation pattern </param>
        /// <param name="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'). </param>
        public virtual 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);
        }
Example #3
0
 /// <summary>
 /// Add a character class to the tree. It is used by
 /// <see cref="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.
 /// </summary>
 public virtual 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];
             m_classmap.Insert(key, 0, equivChar);
         }
     }
 }