MCPcopy Create free account
hub / github.com/RingBDStack/GDAP / annotate_span

Method annotate_span

data_convert/format/text2target.py:132–168  ·  view source on GitHub ↗

src: source text traget: ((ET)) 只对ET进行生成, ((ET)(ET)...) :param tokens: US President George W. Bush told Canadian Prime Minister Jean Chretien by telephone Monday that he looked forward to seeing him at the upcoming summit of major industrialized nat

(tokens, predicate_arguments, mark_tree=False, zh=False)

Source from the content-addressed store, hash-verified

130
131 @staticmethod
132 def annotate_span(tokens, predicate_arguments, mark_tree=False, zh=False):
133 """
134 src: source text
135 traget: ((ET)) 只对ET进行生成, ((ET)(ET)...)
136 :param tokens:
137 US President George W. Bush told Canadian Prime Minister Jean Chretien by telephone Monday that he looked forward
138 to seeing him at the upcoming summit of major industrialized nations and Russia , the White House said Tuesday .
139 :param predicate_arguments:
140
141 :return:
142 """
143
144 token_separator = '' if zh else ' '
145
146 et_list = []
147
148 # 去除重复的事件类型
149 et_set = set()
150
151 # 遍历event
152 for predicate_argument in predicate_arguments:
153 event_type = predicate_argument['type']
154 if event_type in et_set: continue
155 else: et_set.add(event_type)
156
157 # 在此处修改 source 与 target 格式
158
159 et_text = f'{type_start} ' + event_type + f' {type_end}'
160 # et_text = event_type
161 et_list.append(et_text)
162
163 source_text = token_separator.join(tokens)
164 target_text = f'{type_start} ' + " ".join(et_list) + f' {type_end}'
165 # target_text = " ".join(et_list)
166
167
168 return [source_text], [target_text]
169
170# et + src -> ((tri)) 遍历事件类型, 针对每个给定的事件类型生成触发词(如果包含)
171class ETText2Tri(TargetFormat):

Callers 1

convert_file_tupleFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected