Beispiel #1
0
        /**
         * <summary>The transitionPossible method takes a {@link FsmParse} currentFsmParse as an input. It then checks some special cases;</summary>
         *
         * <param name="currentFsmParse">Parse to be checked</param>
         * <returns>true if transition is possible false otherwise</returns>
         */
        public bool TransitionPossible(FsmParse currentFsmParse)
        {
            if (_with == "Ar" && currentFsmParse.GetSurfaceForm().EndsWith("l") &&
                currentFsmParse.GetWord().GetName() != currentFsmParse.GetSurfaceForm())
            {
                return(false);
            }

            if (currentFsmParse.GetVerbAgreement() != null && currentFsmParse.GetPossessiveAgreement() != null &&
                _withName != null)
            {
                if (currentFsmParse.GetVerbAgreement() == "A3PL" && _withName == "^DB+VERB+ZERO+PRES+A1SG")
                {
                    return(false);
                }

                if (currentFsmParse.GetVerbAgreement() == "A3SG" &&
                    (currentFsmParse.GetPossessiveAgreement() == "P1SG" ||
                     currentFsmParse.GetPossessiveAgreement() == "P2SG") &&
                    _withName == "^DB+VERB+ZERO+PRES+A1PL")
                {
                    return(false);
                }
            }

            return(true);
        }
        /**
         * <summary>The getParseWithLongestRootWord method returns the parse with the longest root word. If more than one parse has the
         * longest root word, the first parse with that root is returned.</summary>
         *
         * <returns>FsmParse Parse with the longest root word.</returns>
         */
        public FsmParse GetParseWithLongestRootWord()
        {
            var      maxLength = -1;
            FsmParse bestParse = null;

            foreach (var currentParse in _fsmParses)
            {
                if (currentParse.GetWord().GetName().Length > maxLength)
                {
                    maxLength = currentParse.GetWord().GetName().Length;
                    bestParse = currentParse;
                }
            }

            return(bestParse);
        }
        /**
         * <summary>The overridden clone method creates a new {@link FsmParse} abject with root variable and initializes variables form, pos,
         * initialPos, verbAgreement, possessiveAgreement, and also the {@link ArrayList}s suffixList, formList, transitionList and withList.
         * Then returns newly created and cloned {@link FsmParse} object.</summary>
         *
         * <returns>FsmParse object.</returns>
         */
        public object Clone()
        {
            int i;
            var p = new FsmParse(root)
            {
                _form                = _form,
                _pos                 = _pos,
                _initialPos          = _initialPos,
                _verbAgreement       = _verbAgreement,
                _possessiveAgreement = _possessiveAgreement,
                _suffixList          = new List <State>()
            };

            for (i = 0; i < _suffixList.Count; i++)
            {
                p._suffixList.Add(_suffixList[i]);
            }

            p._formList = new List <string>();
            for (i = 0; i < _formList.Count; i++)
            {
                p._formList.Add(_formList[i]);
            }

            p._transitionList = new List <string>();
            for (i = 0; i < _transitionList.Count; i++)
            {
                p._transitionList.Add(_transitionList[i]);
            }

            p._withList = new List <string>();
            for (i = 0; i < _withList.Count; i++)
            {
                p._withList.Add(_withList[i]);
            }

            return(p);
        }