/// <summary> /// Проверка, что текущее подпредложение должно быть частью предыдущего подпредложения /// </summary> /// <param name="previous">предыдущее подпредложение</param> /// <returns>результат проверки</returns> private bool IsCurrentPartOfPrevious(SubSentenceInfo previous) { #region [.defense.] if (CurrentSubSentence.IsContainConjunction) { throw new InvalidOperationException("Current subsentence have conjunction"); } #endregion bool result = false; switch (previous.SubSentence.Type) { case SubSentenceType.DanglingParticiple: case SubSentenceType.Participial: result = !(CurrentSubSentence.IsExistVerb() || CurrentSubSentence.IsExistSubject()); break; case SubSentenceType.Default: case SubSentenceType.Subordinate: result = !(CurrentSubSentence.IsExistVerb() && previous.IsExistVerb()) && !((CurrentSubSentence.IsHasLingvisticEntity() || CurrentSubSentence.SubSentence.Children.Any()) && (previous.IsHasLingvisticEntity() || previous.SubSentence.Children.Any())); break; } return(result); }
/// <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); }