예제 #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Given a start character position that is within a word, and a direction
        /// return the index of the first non-wordforming (and non-number) character in that direction,
        /// or -1 if the start of the string is reached, or string.Length if the end is reached.
        /// For our purposes here, ORC (0xfffc) is considered word-forming.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private int AdjustWordBoundary(ILgWritingSystemFactory wsf, ITsString tss, bool forward,
                                       int ichStart, int lim)
        {
            int ich;

            for (ich = NextCharIndex(tss, forward, ichStart); !BeyondLim(forward, ich, lim); ich = NextCharIndex(tss, forward, ich))
            {
                int ch = tss.CharAt(ich);
                ILgWritingSystem ws = wsf.get_EngineOrNull(tss.get_WritingSystemAt(ich));
                if (!ws.get_IsWordForming(ch) && !Icu.Character.IsNumeric(ch) && ch != 0xfffc)
                {
                    break;
                }
            }
            return(ich);
        }
예제 #2
0
        /// <summary>
        /// Run the method, return true if match (i.e., found a spelling error).
        /// </summary>
        /// <returns></returns>
        public bool Run()
        {
            //if we have no valid dictionary then all the words must be spelled right?
            if (m_dict == null)
            {
                return(false);
            }
            int  ichMinWord = 0;
            bool fInWord    = false;

            for (int ich = 0; ich < m_cch; ich++)
            {
                bool isWordForming = m_ws.get_IsWordForming(m_text[ich]);
                if (isWordForming)
                {
                    if (!fInWord)
                    {
                        fInWord    = true;
                        ichMinWord = ich;
                    }
                }
                else
                {
                    if (fInWord)
                    {
                        if (CheckWord(ichMinWord, ich))
                        {
                            return(true);
                        }
                        fInWord = false;
                    }
                }
            }
            if (fInWord)
            {
                return(CheckWord(ichMinWord, m_cch));
            }
            return(false);
        }