Example #1
0
        public void ReplaceWordsByLength(int sentenceIndex, int length, ISentence sentenceItems)
        {
            ISentence sentence = this[sentenceIndex];

            if (sentenceItems != null)
            {
                int startIndex = -1; int count = 0; int index;
                while (true)
                {
                    if ((startIndex + 1 + count) <= sentence.Count)
                    {
                        index = sentence.ToList().
                                FindIndex(startIndex + 1 + count, x => x.Length == length);
                    }
                    else
                    {
                        break;
                    }
                    startIndex = index;
                    count      = sentenceItems.Count;

                    if (startIndex != -1)
                    {
                        sentence.RemoveAtIndex(index - 1);
                        sentence.RemoveAtIndex(index - 1);
                        sentence.InsertSentenceItemsByIndex(index - 1, sentenceItems.SentenceItems);
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }