def map_tokens_to_terms(self,list_tokens):
        """
        Maps a list of token ids to the corresponding term ids
        @type list_tokens: list
        @param list_tokens: list of token identifiers
        @rtype: list
        @return: list of term idenfitiers
        """
        if self.terms_for_token is None:
            self.terms_for_token = {}
            for term in self.get_terms():
                termid = term.get_id()
                token_ids = term.get_span().get_span_ids()
                for tokid in token_ids:
                    if tokid not in self.terms_for_token:
                        self.terms_for_token[tokid] = [termid]
                    else:
                        self.terms_for_token[tokid].append(termid)

        ret = set()
        for my_id in list_tokens:
            term_ids = self.terms_for_token.get(my_id,[])
            ret |= set(term_ids)
        return sorted(list(ret))
def map_tokens_to_terms ( self , list_tokens ) : if self . terms_for_token is None : self . terms_for_token = { } for term in self . get_terms ( ) : termid = term . get_id ( ) token_ids = term . get_span ( ) . get_span_ids ( ) for tokid in token_ids : if tokid not in self . terms_for_token : self . terms_for_token [ tokid ] = [ termid ] else : self . terms_for_token [ tokid ] . append ( termid ) ret = set ( ) for my_id in list_tokens : term_ids = self . terms_for_token . get ( my_id , [ ] ) ret |= set ( term_ids ) return sorted ( list ( ret ) )
Maps a list of token ids to the corresponding term ids
        @type list_tokens: list
        @param list_tokens: list of token identifiers
        @rtype: list
        @return: list of term idenfitiers