Ejemplo n.º 1
0
        public IEnumerable <string> Word2Slogs(string word)
        {
            var             sb    = new StringBuilder();
            Predicate <int> case1 = index => word[index] == 'й' && Soglas.Contains(word[index + 1]);
            Predicate <int> case2 = index => Zvonk.Contains(word[index]) && Gluh.Contains(word[index + 1]);
            int             i     = 0;

            for (; GlasLeft(word, i) > 1 || sb.Length != 0; i++)
            {
                sb.Append(word[i]);
                if (case1(i) || case2(i) || Glas.Contains(word[i]) && !(case1(i) || case2(i)))
                {
                    yield return(sb.Append('-').ToString());

                    sb.Clear();
                }
            }
            yield return(word.Substring(i));
        }
Ejemplo n.º 2
0
        public static IEnumerable <string> GetSlogs(string input)
        {
            if (!String.IsNullOrWhiteSpace(input))
            {
                var             sb    = new StringBuilder();
                Predicate <int> case1 = index => input[index] == 'й' && Soglas.Contains(input[index + 1]);
                Predicate <int> case2 = index => Zvonk.Contains(input[index]) && Gluh.Contains(input[index + 1]);
                int             i     = 0;
                for (; GlasLeft(input, i) > 1 || sb.Length != 0; i++)
                {
                    sb.Append(input[i]);
                    if (case1(i) || case2(i) || Glas.Contains(input[i]) && !(case1(i) || case2(i)))
                    {
                        yield return(sb.Append('-').ToString());

                        sb.Clear();
                    }
                }

                yield return(input.Substring(i));
            }
        }