コード例 #1
0
        /// <summary>
        /// Sets the character confidence.
        /// </summary>
        /// <param name="iCharIndex">Index of the i character.</param>
        /// <param name="iCandidateIndex">Index of the i candidate.</param>
        /// <param name="iCharConfi">The i character confi.</param>
        /// <param name="bWordOrder">if set to <c>true</c> [b word order].</param>
        public void SetCharConfidence(int iCharIndex, int iCandidateIndex, int iCharConfi, bool bWordOrder)
        {
            TBasicChar oCharCandidate = (m_oWorkingWord.Chars[iCharIndex] as TChar).m_oCharCandidate[iCandidateIndex] as TBasicChar;

            oCharCandidate.m_iConfidance = (iCharConfi * m_iCharConfiFactor) / 100;
            if (bWordOrder)
            {
                FixWordOrder();
            }
        }
コード例 #2
0
 // Add candidate (remove duplicated is exist)
 /// <summary>
 /// Adds the candidate.
 /// </summary>
 /// <param name="oNewCandidate">The o new candidate.</param>
 public void AddCandidate(TChar oNewCandidate)
 {
     foreach (TBasicChar oNewChar in oNewCandidate)
     {
         Boolean bAdd = false;
         int     iIdx = -1;
         // Check if we already have candidate with the same data
         for (int i = 0; (i < m_oCharCandidate.Count) && (iIdx < 0); i++)
         {
             TBasicChar oChar = (TBasicChar)m_oCharCandidate[i];
             if (oChar.CharData == oNewChar.CharData)
             {
                 iIdx = i;
             }
         }
         //int iIdx = m_oCharCandidate.BinarySearch( oNewChar ) ; xxx
         if (iIdx >= 0)
         {
             TBasicChar oExistChar = (TBasicChar)(m_oCharCandidate[iIdx]);
             // The same character have lower confidence - so we now replace the old with the new
             if (oExistChar.CompareTo(oNewChar) > 0)
             {
                 m_oCharCandidate.RemoveAt(iIdx);
                 bAdd = true;
             }
         }
         else
         {
             bAdd = true;
         }
         if (bAdd)
         {
             // Add the new candidate (& sort acurding the candidates confidence )
             m_oCharCandidate.Add(oNewChar);
             m_oCharCandidate.Sort();
             // In case the new candidate is the best, then we take also the char rectangle.
             if (m_oCharCandidate[0] == oNewChar)
             {
                 m_oRectangle = oNewCandidate.m_oRectangle;
             }
         }
     }
 }