Datasets:
Commit ·
0f83d1c
1
Parent(s): 5b7f6c0
Update multiconer_v2.py
Browse files286 unmodified lines287288289290291292293294295296297298299300301302303304305306307308309310311312313314286 unmodified lineslogger.info("⏳ Generating examples from = %s", filepath)with open(filepath, encoding="utf-8") as f:guid = 0tokens = []ner_tags = []for line in f.read().strip().split('\n'):if line.startswith("# id") or line == "" or line == "\n" or "_ _" not in line:if tokens:yield guid, {"id": str(guid),"tokens": tokens,"ner_tags": ner_tags,}guid += 1tokens = []ner_tags = []else:# Separator is " _ _ "splits = line.split("_ _")tokens.append(splits[0].strip())ner_tags.append(splits[1].strip())# last exampleyield guid, {"id": str(guid),"tokens": tokens,"ner_tags": ner_tags,}286 unmodified lines287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320286 unmodified lineslogger.info("⏳ Generating examples from = %s", filepath)with open(filepath, encoding="utf-8") as f:guid = 0s_id = Nonetokens = []ner_tags = []for line in f.read().strip().split('\n'):if line.startswith("# id"):s_id = line.split('\t')[0].split(' ')[-1].strip()tokens = []ner_tags = []elif len(line.strip()) == 0:if s_id and len(tokens) >=1 and len(tokens) == len(ner_tags):yield guid, {"id": s_id,"tokens": tokens,"ner_tags": ner_tags,}guid += 1s_id = Nonetokens = []ner_tags = []else:# Separator is " _ _ "splits = line.split(" _ _ ")tokens.append(splits[0].strip())ner_tags.append(splits[1].strip())# last exampleyield guid, {"id": s_id,"tokens": tokens,"ner_tags": ner_tags,}
multiconer_v2.py+11-5