intficpy/parser.py
def checkAdjectives(
        self, noun_adj_arr, noun, things, scope, far_obj, obj_direction
    ):
        """
        If there are multiple Thing objects matching the noun, check the adjectives to
        narrow down to exactly 1
        Takes arguments self.game.app, noun_adj_arr, a list of strings referring to an in game item,
        taken from the player command,noun (string), things, a list of Thing objects
        (things.py) that are     candidates for the target of the player's action, and
        scope, a string specifying the range of the verb
        Returns a single Thing object or None
        """
        if things == self.previous_command.things:
            try:
                n_select = int(noun_adj_arr[0])
            except ValueError:
                n_select = None
            if n_select is not None and n_select <= len(things):
                n_select = n_select - 1
                return things[n_select]
        if noun:
            adj_i = noun_adj_arr.index(noun) - 1
        else:
            adj_i = len(noun_adj_arr) - 1
        not_match = []
        while adj_i >= 0 and len(things) > 1:
            # check preceding word as an adjective
            for thing in things:
                if noun_adj_arr[adj_i] not in thing.adjectives:
                    not_match.append(thing)
            for item in not_match:
                if item in things:
                    things.remove(item)
            adj_i = adj_i - 1
        things = self.checkRange(things, scope)
        if len(things) == 1 and things[0].far_away and not far_obj:
            self.game.addTextToEvent(
                "turn",
                (things[0].getArticle(True) + things[0].verbose_name).capitalize()
                + " is too far away. ",
            )
            return False
        elif len(things) > 1 and not far_obj:
            remove_far = []
            for item in things:
                if item.far_away:
                    remove_far.append(item)
            if len(things) > len(remove_far):
                for item in remove_far:
                    things.remove(item)
        if len(things) > 1 and obj_direction:
            remove_wrong = []
            for item in things:
                if item.direction:
                    if item.direction != obj_direction:
                        remove_wrong.append(item)
            if len(things) > len(remove_wrong):
                for item in remove_wrong:
                    if item in things:
                        things.remove(item)
        if len(things) > 1:
            remove_child = []
            for item in things:
                if item.is_composite:
                    for item2 in things:
                        if item2 in item.children:
                            remove_child.append(item2)
            if len(things) > len(remove_child):
                for item in remove_child:
                    if item in things:
                        things.remove(item)

        if len(things) == 1:
            return things[0]

        if len(things) == 0:
            return None

        if len(things) > 1:
            if len(set([thing.ix for thing in things])) == 1:
                loc = things[0].location
                same_loc = True
                for thing in things:
                    if thing.location is not loc:
                        same_loc = False
                if same_loc:
                    return things[0]

            msg = self._generateDisambigMsg(things, "Do you mean ")
            # turn ON disambiguation mode for next turn
            self.command.ambiguous = True
            self.command.ambig_noun = noun
            self.command.things = things
            raise ObjectMatchError(msg)

        If there are multiple Thing objects matching the noun, check the adjectives to
        narrow down to exactly 1
        Takes arguments self.game.app, noun_adj_arr, a list of strings referring to an in game item,
        taken from the player command,noun (string), things, a list of Thing objects
        (things.py) that are     candidates for the target of the player's action, and
        scope, a string specifying the range of the verb
        Returns a single Thing object or None
        
If there are multiple Thing objects matching the noun, check the adjectives to
narrow down to exactly 1
Takes arguments self.game.app, noun_adj_arr, a list of strings referring to an in game item,
taken from the player command,noun (string), things, a list of Thing objects
(things.py) that are     candidates for the target of the player's action, and
scope, a string specifying the range of the verb
Returns a single Thing object or None
If there are multiple Thing objects matching the noun check the adjectives to narrow down to exactly 1 Takes arguments self . game . app noun_adj_arr a list of strings referring to an in game item taken from the player command noun ( string ) things a list of Thing objects ( things . py ) that are candidates for the target of the player ' s action and scope a string specifying the range of the verb Returns a single Thing object or None
def checkAdjectives(
        self, noun_adj_arr, noun, things, scope, far_obj, obj_direction
    ):
        if things == self.previous_command.things:
            try:
                n_select = int(noun_adj_arr[0])
            except ValueError:
                n_select = None
            if n_select is not None and n_select <= len(things):
                n_select = n_select - 1
                return things[n_select]
        if noun:
            adj_i = noun_adj_arr.index(noun) - 1
        else:
            adj_i = len(noun_adj_arr) - 1
        not_match = []
        while adj_i >= 0 and len(things) > 1:
            for thing in things:
                if noun_adj_arr[adj_i] not in thing.adjectives:
                    not_match.append(thing)
            for item in not_match:
                if item in things:
                    things.remove(item)
            adj_i = adj_i - 1
        things = self.checkRange(things, scope)
        if len(things) == 1 and things[0].far_away and not far_obj:
            self.game.addTextToEvent(
                "turn",
                (things[0].getArticle(True) + things[0].verbose_name).capitalize()
                + " is too far away. ",
            )
            return False
        elif len(things) > 1 and not far_obj:
            remove_far = []
            for item in things:
                if item.far_away:
                    remove_far.append(item)
            if len(things) > len(remove_far):
                for item in remove_far:
                    things.remove(item)
        if len(things) > 1 and obj_direction:
            remove_wrong = []
            for item in things:
                if item.direction:
                    if item.direction != obj_direction:
                        remove_wrong.append(item)
            if len(things) > len(remove_wrong):
                for item in remove_wrong:
                    if item in things:
                        things.remove(item)
        if len(things) > 1:
            remove_child = []
            for item in things:
                if item.is_composite:
                    for item2 in things:
                        if item2 in item.children:
                            remove_child.append(item2)
            if len(things) > len(remove_child):
                for item in remove_child:
                    if item in things:
                        things.remove(item)
        if len(things) == 1:
            return things[0]
        if len(things) == 0:
            return None
        if len(things) > 1:
            if len(set([thing.ix for thing in things])) == 1:
                loc = things[0].location
                same_loc = True
                for thing in things:
                    if thing.location is not loc:
                        same_loc = False
                if same_loc:
                    return things[0]
            msg = self._generateDisambigMsg(things, "Do you mean ")
            self.command.ambiguous = True
            self.command.ambig_noun = noun
            self.command.things = things
            raise ObjectMatchError(msg)
def checkAdjectives ( self , noun_adj_arr , noun , things , scope , far_obj , obj_direction ) : if things == self . previous_command . things : try : n_select = int ( noun_adj_arr [ 0 ] ) except ValueError : n_select = None if n_select is not None and n_select <= len ( things ) : n_select = n_select - 1 return things [ n_select ] if noun : adj_i = noun_adj_arr . index ( noun ) - 1 else : adj_i = len ( noun_adj_arr ) - 1 not_match = [ ] while adj_i >= 0 and len ( things ) > 1 : for thing in things : if noun_adj_arr [ adj_i ] not in thing . adjectives : not_match . append ( thing ) for item in not_match : if item in things : things . remove ( item ) adj_i = adj_i - 1 things = self . checkRange ( things , scope ) if len ( things ) == 1 and things [ 0 ] . far_away and not far_obj : self . game . addTextToEvent ( "turn" , ( things [ 0 ] . getArticle ( True ) + things [ 0 ] . verbose_name ) . capitalize ( ) + " is too far away. " , ) return False elif len ( things ) > 1 and not far_obj : remove_far = [ ] for item in things : if item . far_away : remove_far . append ( item ) if len ( things ) > len ( remove_far ) : for item in remove_far : things . remove ( item ) if len ( things ) > 1 and obj_direction : remove_wrong = [ ] for item in things : if item . direction : if item . direction != obj_direction : remove_wrong . append ( item ) if len ( things ) > len ( remove_wrong ) : for item in remove_wrong : if item in things : things . remove ( item ) if len ( things ) > 1 : remove_child = [ ] for item in things : if item . is_composite : for item2 in things : if item2 in item . children : remove_child . append ( item2 ) if len ( things ) > len ( remove_child ) : for item in remove_child : if item in things : things . remove ( item ) if len ( things ) == 1 : return things [ 0 ] if len ( things ) == 0 : return None if len ( things ) > 1 : if len ( set ( [ thing . ix for thing in things ] ) ) == 1 : loc = things [ 0 ] . location same_loc = True for thing in things : if thing . location is not loc : same_loc = False if same_loc : return things [ 0 ] msg = self . _generateDisambigMsg ( things , "Do you mean " ) self . command . ambiguous = True self . command . ambig_noun = noun self . command . things = things raise ObjectMatchError ( msg )
If there are multiple Thing objects matching the noun, check the adjectives to
narrow down to exactly 1
Takes arguments self.game.app, noun_adj_arr, a list of strings referring to an in game item,
taken from the player command,noun (string), things, a list of Thing objects
(things.py) that are     candidates for the target of the player's action, and
scope, a string specifying the range of the verb
Returns a single Thing object or None
If there are multiple Thing objects matching the noun check the adjectives to narrow down to exactly 1 Takes arguments self . game . app noun_adj_arr a list of strings referring to an in game item taken from the player command noun ( string ) things a list of Thing objects ( things . py ) that are candidates for the target of the player ' s action and scope a string specifying the range of the verb Returns a single Thing object or None
"""
        If there are multiple Thing objects matching the noun, check the adjectives to
        narrow down to exactly 1
        Takes arguments self.game.app, noun_adj_arr, a list of strings referring to an in game item,
        taken from the player command,noun (string), things, a list of Thing objects
        (things.py) that are     candidates for the target of the player's action, and
        scope, a string specifying the range of the verb
        Returns a single Thing object or None
        """ # check preceding word as an adjective # turn ON disambiguation mode for next turn
self
noun_adj_arr
noun
things
scope
far_obj
obj_direction