Exemple #1
0
        public string ReplaceJosa(string src)
        {
            tmpStringBuilder.Length = 0;
            string          text             = StripTags(src);
            int             num              = 0;
            MatchCollection matchCollection  = JosaPattern.Matches(src);
            MatchCollection matchCollection2 = JosaPattern.Matches(text);

            if (matchCollection2.Count < matchCollection.Count)
            {
                return(src);
            }
            for (int i = 0; i < matchCollection.Count; i++)
            {
                Match    match    = matchCollection[i];
                Match    match2   = matchCollection2[i];
                JosaPair josaPair = JosaPatternPaired[match.Value];
                tmpStringBuilder.Append(src, num, match.Index - num);
                if (match.Index > 0)
                {
                    char   inChar = text[match2.Index - 1];
                    string value  = (((match.Value == "(으)로") ? HasJongExceptRieul(inChar) : HasJong(inChar)) ? josaPair.josa1 : josaPair.josa2);
                    tmpStringBuilder.Append(value);
                }
                else
                {
                    tmpStringBuilder.Append(josaPair.josa2);
                }
                num = match.Index + match.Length;
            }
            tmpStringBuilder.Append(src, num, src.Length - num);
            return(tmpStringBuilder.ToString());
        }
        public string ReplaceJosa(string src)
        {
            tmpStringBuilder.Length = 0;
            MatchCollection matchCollection = JosaPattern.Matches(src);
            int             num             = 0;

            for (int i = 0; i < matchCollection.Count; i++)
            {
                Match    match    = matchCollection[i];
                JosaPair josaPair = JosaPatternPaired[match.Value];
                tmpStringBuilder.Append(src, num, match.Index - num);
                if (match.Index > 0)
                {
                    char inChar = src[match.Index - 1];
                    if ((match.Value != "(으)로" && HasJong(inChar)) || (match.Value == "(으)로" && HasJongExceptRieul(inChar)))
                    {
                        tmpStringBuilder.Append(josaPair.josa1);
                    }
                    else
                    {
                        tmpStringBuilder.Append(josaPair.josa2);
                    }
                }
                else
                {
                    tmpStringBuilder.Append(josaPair.josa1);
                }
                num = match.Index + match.Length;
            }
            tmpStringBuilder.Append(src, num, src.Length - num);
            return(tmpStringBuilder.ToString());
        }