def align_chunk_with_ner(tmp_ner_path, i_chunk, tmp_done_path):
o_chunk = Chunk()<EOL>input_iter = i_chunk.__iter__()<EOL>ner = '<STR_LIT>'<EOL>stream_id = None<EOL>all_ner = xml.dom.minidom.parse(open(tmp_ner_path))<EOL>for raw_ner in all_ner.getElementsByTagName('<STR_LIT>'):<EOL><INDENT>stream_item = next(input_iter)<EOL>stream_id = raw_ner.attributes.get('<STR_LIT>').value<EOL>assert stream_id and stream_id == stream_item.stream_id,'<STR_LIT>' % (stream_id, stream_item.stream_id, ner)<EOL>tagger_id = '<STR_LIT>'<EOL>tagging = Tagging()<EOL>tagging.tagger_id = tagger_id<EOL>tagged_doc = list(lingpipe.files(raw_ner.toxml()))[<NUM_LIT:0>][<NUM_LIT:1>]<EOL>tagging.raw_tagging = tagged_doc<EOL>tagging.generation_time = streamcorpus.make_stream_time()<EOL>stream_item.body.taggings[tagger_id] = tagging<EOL>sentences = list(lingpipe.sentences(tagged_doc))<EOL>assert stream_item.ratings[<NUM_LIT:0>].mentions, stream_item.stream_id<EOL>john_smith_label = Label()<EOL>john_smith_label.annotator = stream_item.ratings[<NUM_LIT:0>].annotator<EOL>john_smith_label.target_id = stream_item.ratings[<NUM_LIT:0>].target_id<EOL>equiv_ids = collections.defaultdict(lambda: set())<EOL>for sent in sentences:<EOL><INDENT>for tok in sent.tokens:<EOL><INDENT>if tok.entity_type is not None:<EOL><INDENT>equiv_ids[tok.equiv_id].add(cleanse(tok.token))<EOL><DEDENT><DEDENT><DEDENT>johnsmiths = set()<EOL>for equiv_id, names in list(equiv_ids.items()):<EOL><INDENT>_names = cleanse('<STR_LIT:U+0020>'.join(names))<EOL>if '<STR_LIT>' in _names and '<STR_LIT>' in _names:<EOL><INDENT>johnsmiths.add(equiv_id)<EOL><DEDENT><DEDENT>print(len(johnsmiths))<EOL>for sent in sentences:<EOL><INDENT>for tok in sent.tokens:<EOL><INDENT>if tok.equiv_id in johnsmiths:<EOL><INDENT>tok.labels = [john_smith_label]                <EOL><DEDENT><DEDENT><DEDENT>stream_item.body.sentences[tagger_id] = sentences<EOL>o_chunk.add(stream_item)<EOL><DEDENT>open(tmp_done_path, '<STR_LIT:wb>').write(str(o_chunk))<EOL>print('<STR_LIT>' % tmp_done_path)<EOL>
iterate through the i_chunk and tmp_ner_path to generate a new
Chunk with body.ner