def test_morphologicalAnalysisIsPortmanteau(self):
     dictionary = self.fsm.getDictionary()
     for i in range(dictionary.size()):
         word = dictionary.getWordWithIndex(i)
         if isinstance(word, TxtWord):
             if word.isNominal() and word.isPortmanteau() and not word.isPlural() and \
                     not word.isPortmanteauFacedVowelEllipsis():
                 transitionState = State("CompoundNounRoot", True, False)
                 startState = State("CompoundNounRoot", True, False)
                 transition = Transition("lArH", transitionState,
                                         "A3PL+P3PL")
                 exceptLast2 = word.getName()[:len(word.getName()) - 2]
                 exceptLast = word.getName()[:len(word.getName()) - 1]
                 if word.isPortmanteauFacedSoftening():
                     if word.getName()[len(word.getName()) - 2] == "b":
                         rootForm = exceptLast2 + 'p'
                     elif word.getName()[len(word.getName()) - 2] == "c":
                         rootForm = exceptLast2 + 'ç'
                     elif word.getName()[len(word.getName()) - 2] == "d":
                         rootForm = exceptLast2 + 't'
                     elif word.getName()[len(word.getName()) - 2] == "ğ":
                         rootForm = exceptLast2 + 'k'
                     else:
                         rootForm = exceptLast
                 else:
                     if word.isPortmanteauEndingWithSI():
                         rootForm = exceptLast2
                     else:
                         rootForm = exceptLast
                 surfaceForm = transition.makeTransition(
                     word, rootForm, startState)
                 self.assertTrue(
                     self.fsm.morphologicalAnalysis(surfaceForm).size() != 0
                 )
 def test_morphologicalAnalysisVowelAChangesToIDuringYSuffixation(self):
     dictionary = self.fsm.getDictionary()
     for i in range(dictionary.size()):
         word = dictionary.getWordWithIndex(i)
         if isinstance(word, TxtWord):
             if word.isVerb() and word.vowelAChangesToIDuringYSuffixation():
                 transitionState = State("VerbalStem", False, False)
                 startState = State("VerbalRoot", True, False)
                 transition = Transition("Hyor", transitionState, "PROG1")
                 surfaceForm = transition.makeTransition(
                     word, word.getName(), startState)
                 self.assertTrue(
                     self.fsm.morphologicalAnalysis(surfaceForm).size() != 0
                 )
 def test_morphologicalAnalysisNounSoftenDuringSuffixation(self):
     dictionary = self.fsm.getDictionary()
     for i in range(dictionary.size()):
         word = dictionary.getWordWithIndex(i)
         if isinstance(word, TxtWord):
             if word.isNominal() and word.nounSoftenDuringSuffixation():
                 transitionState = State("Possessive", False, False)
                 startState = State("NominalRoot", True, False)
                 transition = Transition("yH", transitionState, "ACC")
                 surfaceForm = transition.makeTransition(
                     word, word.getName(), startState)
                 self.assertTrue(
                     self.fsm.morphologicalAnalysis(surfaceForm).size() != 0
                 )
 def test_morphologicalAnalysisLastIdropsDuringPassiveSuffixation(self):
     dictionary = self.fsm.getDictionary()
     for i in range(dictionary.size()):
         word = dictionary.getWordWithIndex(i)
         if isinstance(word, TxtWord):
             if word.isVerb() and word.lastIdropsDuringPassiveSuffixation():
                 transitionState = State("VerbalStem", False, False)
                 startState = State("VerbalRoot", True, False)
                 transition = Transition("Hl", transitionState,
                                         "^DB+VERB+PASS")
                 surfaceForm = transition.makeTransition(
                     word, word.getName(), startState)
                 self.assertTrue(
                     self.fsm.morphologicalAnalysis(surfaceForm).size() != 0
                 )
    def addTransition(self, fromState: State, toState: State, _with: str, withName: str, toPos=None):
        """
        Another addTransition method which takes additional argument; toPos and. It creates a new Transition
        with given input parameters and adds the transition to transitions list.

        PARAMETERS
        ----------
        fromState : State
            State type input indicating the previous state.
        toState : State
            State type input indicating the next state.
        _with : str
            String input indicating with what the transition will be made.
        withName : str
            String input.
        toPos : str
            String input.
        """
        newTransition = Transition(_with, toState, withName, toPos)
        if fromState in self.__transitions:
            transitionList = self.__transitions[fromState]
        else:
            transitionList = []
        transitionList.append(newTransition)
        self.__transitions[fromState] = transitionList
示例#6
0
 def addTransition(self,
                   fromState: State,
                   toState: State,
                   _with: str,
                   withName: str,
                   toPos=None):
     newTransition = Transition(_with, toState, withName, toPos)
     if fromState in self.__transitions:
         transitionList = self.__transitions[fromState]
     else:
         transitionList = []
     transitionList.append(newTransition)
     self.__transitions[fromState] = transitionList