private void ShuffleMDUnitsBeforeMDBKInDescendingOrder( List <Text> textsAfterBkByBeforeVbVbaPastPres, BKBySentenceDecorator bkBySentenceDecorator) { int MDBKPosition = bkBySentenceDecorator .GetMDBKPosition(textsAfterBkByBeforeVbVbaPastPres); var beforeMDBK = textsAfterBkByBeforeVbVbaPastPres.Take(MDBKPosition).ToList(); MoveableUnit[] MDPositions = ModifierPositionHelper.GetMDUnitPositions(beforeMDBK); if (MDPositions.Any()) { Array.Reverse(MDPositions); List <Text> reversedMDUnit = MoveableUnitHelper.GetTextsFromMoveablePositionsList( beforeMDBK, MDPositions); ReplaceMDUnitBeforeMDBKWithReversedMDUnit( bkBySentenceDecorator, MDPositions, reversedMDUnit); } }
private void ShuffleMDUnitsAfterMDBKInDescendingOrder( List <Text> textsAfterBkByBeforeVbVbaPastPres, BKBySentenceDecorator bKBySentenceDecorator) { int MDBKPosition = bKBySentenceDecorator .GetMDBKPosition(textsAfterBkByBeforeVbVbaPastPres); var afterMDBK = textsAfterBkByBeforeVbVbaPastPres .Skip(MDBKPosition + 1) .ToList(); MoveableUnit[] MDPositions = ModifierPositionHelper.GetMDUnitPositions(afterMDBK); Array.Reverse(MDPositions); List <Text> reversedMDUnit = MoveableUnitHelper.GetTextsFromMoveablePositionsList( afterMDBK, MDPositions); ReplaceMDUnitAfterMDBKWithReversedMDUnit( bKBySentenceDecorator, reversedMDUnit); }
private void ShuffleMDUnitsFromMDBKToBeforeFirstNNAfterBKBy() { int bkByPosition = _bKBySentenceDecorator.BKByIndexPosition; int mdbkposition = _bKBySentenceDecorator.GetMDBKPosition( _bKBySentenceDecorator.Texts); int mdUnitAfterByAndBeforeMDBKStartPosition = _bKBySentenceDecorator .Texts .Skip(bkByPosition) .Take(mdbkposition - bkByPosition) .ToList() .FindIndex(text => text.IsModifier) + bkByPosition; int lastMDPosition = mdbkposition - 1; if (mdUnitAfterByAndBeforeMDBKStartPosition > -1 && lastMDPosition > -1 && lastMDPosition > mdUnitAfterByAndBeforeMDBKStartPosition) { if (_bKBySentenceDecorator.ThereIsAnNNUnitBetweenBKByAndMDBK( _bKBySentenceDecorator, bkByPosition, mdbkposition)) { int NNPosition = _bKBySentenceDecorator .Texts .Skip(bkByPosition) .Take(mdbkposition - bkByPosition) .ToList().FindIndex(text => text.IsNN) + bkByPosition; // remove MD unit var modifierUnitToShuffle = _bKBySentenceDecorator.Texts.GetRange(mdUnitAfterByAndBeforeMDBKStartPosition, lastMDPosition - mdUnitAfterByAndBeforeMDBKStartPosition + 1); _bKBySentenceDecorator.Texts.RemoveRange( mdUnitAfterByAndBeforeMDBKStartPosition, lastMDPosition - mdUnitAfterByAndBeforeMDBKStartPosition + 1); //Insert before the NN _bKBySentenceDecorator.Texts.InsertRange( NNPosition, modifierUnitToShuffle); } } }