Example #1
0
 /// -----------------------------------------------------------------------------------
 /// <summary>
 /// Really do the assignment.
 /// </summary>
 /// <param name="htToBeAssigned">Set of affixes to be assigned.</param>
 /// <param name="lt">Type of list to process.</param>
 /// <param name="fIsStartPoint">True if setting the starting class,
 /// otherwise false.</param>
 /// <param name="cls">The class to set to.</param>
 /// -----------------------------------------------------------------------------------
 protected void DoAssignment(Dictionary <string, MorphemeWrapper> htToBeAssigned, ListType lt,
                             bool fIsStartPoint, Class cls)
 {
     foreach (KeyValuePair <string, MorphemeWrapper> kvp in htToBeAssigned)
     {
         MorphemeWrapper mr = kvp.Value;
         mr.SetAffixClass(fIsStartPoint, cls);
         string mid = mr.GetID();
         m_toCheck.Remove(mid);
         foreach (KeyValuePair <string, MorphemeWrapper> kvpInner in m_toCheck)
         {
             if (lt == ListType.kSucc)
             {
                 kvpInner.Value.RemoveSuccessor(mid);
             }
             else
             {
                 kvpInner.Value.RemovePredecessor(mid);
             }
         }
     }
 }
Example #2
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Gather up a set of affixes to classify.
        /// </summary>
        /// <param name="lt">Type of list to process.</param>
        /// <param name="fInFog">Set to True if the remaining classes are unknowable,
        /// otherwise set to false.</param>
        /// <returns>Set of affixes to work on.</returns>
        /// -----------------------------------------------------------------------------------
        protected Dictionary <string, MorphemeWrapper> GetCandidates(ListType lt, out bool fInFog)
        {
            fInFog = false;
            Dictionary <string, MorphemeWrapper> ht = new Dictionary <string, MorphemeWrapper>();

            foreach (KeyValuePair <string, MorphemeWrapper> kvp in m_toCheck)
            {
                MorphemeWrapper mr = kvp.Value;
                if (mr.CanAssignClass(lt))
                {
                    ht.Add(mr.GetID(), mr);
                }
            }
            if (ht.Count == 0)
            {
                // Couldn't find any, so we have bad input data.
                // Assign all remaining affixes to 'fog' class.
                fInFog = true;
                ht     = new Dictionary <string, MorphemeWrapper>(m_toCheck);
            }
            return(ht);
        }