Esempio n. 1
0
        /// <summary>
        /// Добавление союза в текущее подпредложение
        /// </summary>
        /// <param name="conjunction">союз</param>
        public void AddConjunctionToCurrent(Entity conjunction)
        {
            if (DictionaryResource.IsHomogeneousConjunction(conjunction.Text))
            {
                return;
            }
            UnitTextBase previous = conjunction.GetNonEmptyPrevious();

            if ((previous != null) && previous.IsSeparator(TireForms) && (CurrentSubSentence.StartUnit != previous))
            {
                CreateNewSubSentence(previous.Previous);
            }
            if (CurrentSubSentence.IsContainConjunction)
            {
                if (previous.IsEntity && IsConjunction((Entity)previous))
                {
                    CreateNewSubSentence(previous);
                }
                else
                {
                    return;
                }
            }
            if (CurrentType != SubSentenceType.DanglingParticiple)
            {
                CurrentSubSentence.IsContainConjunction = true;
                CurrentSubSentence.SubSentence.Type     = ((ConjunctionEntityInfo)conjunction.EntityInfo).ConjunctionType;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Проверка, что между двумя юнитами есть однородный союз
        /// </summary>
        /// <param name="begin">начало интервала</param>
        /// <param name="end">конец интервала</param>
        /// <returns>результат проверки</returns>
        private bool IsHomogeneousConjunctionBetween(UnitTextBase begin, UnitTextBase end)
        {
            UnitTextBase current = begin;

            while ((current != null) && (current != end))
            {
                if (DictionaryResource.IsHomogeneousConjunction(current.Text))
                {
                    return(true);
                }
                current = current.GetNonEmptyNext();
            }
            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// Проверка, что текущее подпредложение должно быть частью предыдущего подпредложения
        /// </summary>
        /// <param name="previous">предыдущее подпредложение</param>
        /// <param name="lastAdded">последнее добавленное подпредложение</param>
        /// <returns>результат проверки</returns>
        private bool IsCurrentPartOfPrevious(SubSentenceInfo previous, SubSentenceInfo lastAdded)
        {
            if ((previous != null) && !CurrentSubSentence.IsExistSubject())
            {
                bool isPossiblePart = true;
                if (previous == lastAdded)
                {
                    UnitTextBase firstUnit = CurrentSubSentence.SubSentence.Units.FirstOrDefault(_ => !_.IsEmptyText());
                    if ((firstUnit != null) && !DictionaryResource.IsHomogeneousConjunction(firstUnit.Text))
                    /// подпредложения не будут соединены
                    {
                        isPossiblePart = false;

                        UnitTextBase secondUnit = firstUnit.GetNonEmptyNext();
                        if (IsAnyType(previous.SubSentence, SubSentenceType.Subordinate) && !(CurrentSubSentence.IsContainConjunction ||
                                                                                              (firstUnit.IsSeparator(",") && (secondUnit != null) && DictionaryResource.IsHomogeneousConjunction(secondUnit.Text))))
                        /// не пытаемся восстановить подлежащее
                        {
                            return(false);
                        }
                    }
                }

                if (IsAnyType(previous.SubSentence, SubSentenceType.Default, SubSentenceType.Subordinate))
                {
                    if (IsCurrentSubject(previous.SubSentence.Subject))
                    {
                        if (CurrentSubSentence.IsContainConjunction || (CurrentSubSentence.IsExistVerb() && previous.IsExistVerb()))
                        {
                            CurrentSubSentence.SubSentence.set_SubjectSubSentence(previous.SubSentence);
                        }
                        else
                        {
                            return(isPossiblePart);
                        }
                    }
                }
                else if (!CurrentSubSentence.IsContainConjunction)
                {
                    return(isPossiblePart && IsCurrentPartOfPrevious(previous));
                }
            }
            return(false);
        }
Esempio n. 4
0
 /// <summary>
 /// Создание нового подпредложения по форме глагола
 /// </summary>
 /// <param name="verbForm">форма глагола</param>
 private void CreateNewSubSentenceByVerbForm(Entity verbForm)
 {
     #region [.defense.]
     if (verbForm.UnitTextType != UnitTextType.VERB)
     {
         throw new ArgumentException("entity isn't verbForm");
     }
     #endregion
     Entity       lastVerb = CurrentSubSentence.Verbs.Last();
     UnitTextBase current  = verbForm;
     while (current.Previous != lastVerb)
     {
         if (DictionaryResource.IsHomogeneousConjunction(current.Text) || current.IsSeparator(TireForms) || current.IsSeparator(","))
         {
             break;
         }
         current = current.Previous;
     }
     CreateNewSubSentence(current.Previous);
     AddVerbFormToCurrent(verbForm);
 }