def getSameNamedEntity(self, value, keys): return_key = None # exact match if value in keys: return_key = value # substring match elif self.isSubstring(value, keys) != None: return_key = self.isSubstring(value, keys) # there are just two stock values in whole text, one of them is full name (and added) and the second is abreviation else: # the new value is a abbreviation if Utils.isStockAbbreviation(value): # get all stock roles from text stock_strs = [] for relation in self.text_wrapper.relations: for role in relation.roles: if role.second_level_role == '<actor_stock:1>' and role.filledWithNE() and role.coreferent != None and not Utils.getNamedEntityString(role.coreferent) in stock_strs: stock_strs.append(Utils.getNamedEntityString(role.coreferent)) # primitive check if len(stock_strs) == 2 and len(keys) == 1 and not Utils.isStockAbbreviation(keys[0]): return_key = keys[0] return return_key