Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private void SortModifiersAndMoveModifiersAndPastBeforeNN(Sentence sentence)
        {
            int firstModifierPosition =
                _prenNNPastSentenceDecorator.FirstModifierPosition;

            List <Text> modifiersUpToVBorBK = new List <Text>();

            // _prenNNPastSentenceDecorator.GetModifierUnitUpToVBorBK(firstModifierPosition);

            if (modifiersUpToVBorBK.Count > 1)
            {
                var positions = ModifierPositionHelper.GetMDUnitPositions(
                    modifiersUpToVBorBK);
                if (_prenNNPastSentenceDecorator.ReversableUnitsAreSortedAscending(
                        modifiersUpToVBorBK, text => text.IsModifier))
                {
                    SortReversableUnitInDescendingNumericOrderAndMoveBeforeNN(
                        modifiersUpToVBorBK,
                        firstModifierPosition,
                        _nnPosition,
                        positions);
                }

                MovePastBeforeNN(sentence, UnitTypes.MD_Modifier);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        public Sentence ShuffleSentence(Sentence sentence)
        {
            if (!sentence.HasModifier())
            {
                return(sentence);
            }

            _mdSentenceDecorator =
                new MdSentenceDecorator(sentence);

            List <Text> modifiersUpToVbPastPresOrBkp;

            int firstModifierPosition = _mdSentenceDecorator.FirstModifierPosition;

            if (_mdSentenceDecorator.HasMoreThanOneModifier())
            {
                modifiersUpToVbPastPresOrBkp =
                    _mdSentenceDecorator.GetModifierUnitUpToVbPastPresBkp(firstModifierPosition);

                if (modifiersUpToVbPastPresOrBkp.Count > 1)
                {
                    var mdPositions = ModifierPositionHelper.GetMDUnitPositions(
                        modifiersUpToVbPastPresOrBkp);

                    ReverseModifierUnit(modifiersUpToVbPastPresOrBkp, firstModifierPosition, mdPositions);

                    AddDeParticleToMDUnit(sentence, mdPositions);

                    UnderlineMdUnit(
                        firstModifierPosition,
                        _mdSentenceDecorator.Texts.Skip(firstModifierPosition).ToList().FindIndex(text => text.IsDe()));
                }
            }
            else  // one modifier unit
            {
                modifiersUpToVbPastPresOrBkp =
                    _mdSentenceDecorator.GetModifierUnitUpToVbPastPresBkp(firstModifierPosition);

                UnderlineMdUnit(firstModifierPosition,
                                modifiersUpToVbPastPresOrBkp.Count - 1);
            }

            var textsbeforeMdUnit =
                TextsBefore(firstModifierPosition).ToList();

            if (textsbeforeMdUnit.Any())
            {
                ApplySearchLeftRules(
                    sentence, textsbeforeMdUnit, firstModifierPosition, modifiersUpToVbPastPresOrBkp);
            }

            return(sentence);
        }