intficpy/parser.py
def verbByObjects(self):
        """
        Disambiguates verbs based on syntax used
        Iterates through verb list, comparing syntax in input to the entries in the
        .syntax attribute of the verb
        """
        self.checkForConvCommand()

        match_pairs = []
        for cur_verb in self.command.verb_matches:
            for verb_form in cur_verb.syntax:
                i = len(verb_form)
                for word in verb_form:
                    if word[0] != "<":
                        if word not in self.command.tokens:
                            break
                        else:
                            i = i - 1
                    else:
                        i = i - 1
                if i == 0:
                    match_pairs.append([cur_verb, verb_form])

        removeMatch = []
        for pair in match_pairs:
            verb = pair[0]
            verb_form = pair[1]
            adjacent = False
            if verb.hasDobj:
                d_ix = verb_form.index("<dobj>")
                if not "<dobj>" == verb_form[-1]:
                    if verb_form[d_ix + 1] == "<iobj>":
                        adjacent = True
                if verb_form[d_ix - 1] == "<iobj>":
                    adjacent = True

            if adjacent and verb.dscope in ["text", "direction"]:
                (dobj, iobj) = self._adjacentStrObj(verb_form, "<dobj>") or (None, None)
            elif adjacent and verb.iscope in ["text", "direction"]:
                (dobj, iobj) = self._adjacentStrObj(verb_form, "<iobj>") or (None, None)
            else:
                dobj = self._analyzeSyntax(verb_form, "<dobj>")
                iobj = self._analyzeSyntax(verb_form, "<iobj>")

            pair += [dobj, iobj]

            extra = self.checkExtra(verb, verb_form, dobj, iobj)

            if len(extra) > 0:
                removeMatch.append(pair)

            elif verb.hasDobj and not verb.impDobj and not dobj:
                removeMatch.append(pair)
            elif verb.hasIobj and not verb.impIobj and not iobj:
                removeMatch.append(pair)
            elif (
                verb.dscope == "direction" and not self.directionRangeCheck(dobj)
            ) or (verb.iscope == "direction" and not self.directionRangeCheck(iobj)):
                removeMatch.append(pair)

        for x in removeMatch:
            match_pairs.remove(x)

        if len(match_pairs) == 1:
            self.command.verb = match_pairs[0][0]
            self.command.verb_form = match_pairs[0][1]

            self.command.dobj = GrammarObject(match_pairs[0][2])
            self.command.iobj = GrammarObject(match_pairs[0][3])
            return

        raise ParserError(
            'I understood as far as "'
            + self.command.primary_verb_token
            + '".<br>(Type VERB HELP '
            + self.command.primary_verb_token.upper()
            + " for help with phrasing.) ",
        )

        Disambiguates verbs based on syntax used
        Iterates through verb list, comparing syntax in input to the entries in the
        .syntax attribute of the verb
        
Disambiguates verbs based on syntax used
Iterates through verb list, comparing syntax in input to the entries in the
.syntax attribute of the verb
Disambiguates verbs based on syntax used Iterates through verb list comparing syntax in input to the entries in the . syntax attribute of the verb
def verbByObjects(self):
        self.checkForConvCommand()
        match_pairs = []
        for cur_verb in self.command.verb_matches:
            for verb_form in cur_verb.syntax:
                i = len(verb_form)
                for word in verb_form:
                    if word[0] != "<":
                        if word not in self.command.tokens:
                            break
                        else:
                            i = i - 1
                    else:
                        i = i - 1
                if i == 0:
                    match_pairs.append([cur_verb, verb_form])
        removeMatch = []
        for pair in match_pairs:
            verb = pair[0]
            verb_form = pair[1]
            adjacent = False
            if verb.hasDobj:
                d_ix = verb_form.index("<dobj>")
                if not "<dobj>" == verb_form[-1]:
                    if verb_form[d_ix + 1] == "<iobj>":
                        adjacent = True
                if verb_form[d_ix - 1] == "<iobj>":
                    adjacent = True
            if adjacent and verb.dscope in ["text", "direction"]:
                (dobj, iobj) = self._adjacentStrObj(verb_form, "<dobj>") or (None, None)
            elif adjacent and verb.iscope in ["text", "direction"]:
                (dobj, iobj) = self._adjacentStrObj(verb_form, "<iobj>") or (None, None)
            else:
                dobj = self._analyzeSyntax(verb_form, "<dobj>")
                iobj = self._analyzeSyntax(verb_form, "<iobj>")
            pair += [dobj, iobj]
            extra = self.checkExtra(verb, verb_form, dobj, iobj)
            if len(extra) > 0:
                removeMatch.append(pair)
            elif verb.hasDobj and not verb.impDobj and not dobj:
                removeMatch.append(pair)
            elif verb.hasIobj and not verb.impIobj and not iobj:
                removeMatch.append(pair)
            elif (
                verb.dscope == "direction" and not self.directionRangeCheck(dobj)
            ) or (verb.iscope == "direction" and not self.directionRangeCheck(iobj)):
                removeMatch.append(pair)
        for x in removeMatch:
            match_pairs.remove(x)
        if len(match_pairs) == 1:
            self.command.verb = match_pairs[0][0]
            self.command.verb_form = match_pairs[0][1]
            self.command.dobj = GrammarObject(match_pairs[0][2])
            self.command.iobj = GrammarObject(match_pairs[0][3])
            return
        raise ParserError(
            'I understood as far as "'
            + self.command.primary_verb_token
            + '".<br>(Type VERB HELP '
            + self.command.primary_verb_token.upper()
            + " for help with phrasing.) ",
        )
def verbByObjects ( self ) : self . checkForConvCommand ( ) match_pairs = [ ] for cur_verb in self . command . verb_matches : for verb_form in cur_verb . syntax : i = len ( verb_form ) for word in verb_form : if word [ 0 ] != "<" : if word not in self . command . tokens : break else : i = i - 1 else : i = i - 1 if i == 0 : match_pairs . append ( [ cur_verb , verb_form ] ) removeMatch = [ ] for pair in match_pairs : verb = pair [ 0 ] verb_form = pair [ 1 ] adjacent = False if verb . hasDobj : d_ix = verb_form . index ( "<dobj>" ) if not "<dobj>" == verb_form [ - 1 ] : if verb_form [ d_ix + 1 ] == "<iobj>" : adjacent = True if verb_form [ d_ix - 1 ] == "<iobj>" : adjacent = True if adjacent and verb . dscope in [ "text" , "direction" ] : ( dobj , iobj ) = self . _adjacentStrObj ( verb_form , "<dobj>" ) or ( None , None ) elif adjacent and verb . iscope in [ "text" , "direction" ] : ( dobj , iobj ) = self . _adjacentStrObj ( verb_form , "<iobj>" ) or ( None , None ) else : dobj = self . _analyzeSyntax ( verb_form , "<dobj>" ) iobj = self . _analyzeSyntax ( verb_form , "<iobj>" ) pair += [ dobj , iobj ] extra = self . checkExtra ( verb , verb_form , dobj , iobj ) if len ( extra ) > 0 : removeMatch . append ( pair ) elif verb . hasDobj and not verb . impDobj and not dobj : removeMatch . append ( pair ) elif verb . hasIobj and not verb . impIobj and not iobj : removeMatch . append ( pair ) elif ( verb . dscope == "direction" and not self . directionRangeCheck ( dobj ) ) or ( verb . iscope == "direction" and not self . directionRangeCheck ( iobj ) ) : removeMatch . append ( pair ) for x in removeMatch : match_pairs . remove ( x ) if len ( match_pairs ) == 1 : self . command . verb = match_pairs [ 0 ] [ 0 ] self . command . verb_form = match_pairs [ 0 ] [ 1 ] self . command . dobj = GrammarObject ( match_pairs [ 0 ] [ 2 ] ) self . command . iobj = GrammarObject ( match_pairs [ 0 ] [ 3 ] ) return raise ParserError ( 'I understood as far as "' + self . command . primary_verb_token + '".<br>(Type VERB HELP ' + self . command . primary_verb_token . upper ( ) + " for help with phrasing.) " , )
Disambiguates verbs based on syntax used
Iterates through verb list, comparing syntax in input to the entries in the
.syntax attribute of the verb
Disambiguates verbs based on syntax used Iterates through verb list comparing syntax in input to the entries in the . syntax attribute of the verb
"""
        Disambiguates verbs based on syntax used
        Iterates through verb list, comparing syntax in input to the entries in the
        .syntax attribute of the verb
        """
self