def arrange_resource(wd_mentions_json): document_tokens_dict = dict() for mention_json in wd_mentions_json: mention_data = MentionData.read_json_mention_data_line( mention_json) mention_tokens = mention_data.tokens_number for i in range(0, len(mention_tokens)): doc_id = mention_data.doc_id sent_id = mention_data.sent_id token_map_key = MentionData.static_gen_token_unique_id( doc_id, sent_id, mention_tokens[i]) document_tokens_dict[token_map_key] = mention_data.coref_chain return document_tokens_dict
def extract_within_coref(self, mention: MentionData) -> List[str]: tokens = mention.tokens_number within_coref_token = [] for token_id in tokens: token_x_id = MentionData.static_gen_token_unique_id( str(mention.doc_id), str(mention.sent_id), str(token_id)) if token_x_id in self.within_doc_coref_chain: token_coref_chain = self.within_doc_coref_chain[token_x_id] if token_coref_chain: within_coref_token.append(token_coref_chain) else: within_coref_token.append("-") break return within_coref_token