Upload e3c.py
Browse files29 unmodified lines303132333435363738396 unmodified lines464748495051521 unmodified line54555657585960202 unmodified lines2632642652662672682692704 unmodified lines27527627727827928021 unmodified lines30230330430530630730829 unmodified linesclass E3CConfig(datasets.BuilderConfig):"""BuilderConfig for NCBIDisease"""def __init__(self, **kwargs):"""BuilderConfig for NCBIDisease.Args:**kwargs: keyword arguments forwarded to super."""6 unmodified linesE3CConfig(name="e3c",version=VERSION,description="this is the split of the layer 1 for English of E3C dataset",),]1 unmodified line"""This method specifies the DatasetInfo which contains information and typings."""features = datasets.Features({"tokens": datasets.Sequence(datasets.Value("string")),"ner_tags": datasets.Sequence(datasets.features.ClassLabel(names=[202 unmodified linesArgs:filepath: The path to the folder containing the files to parse.Yields:The unique id of an example and the example itself containing tokens and ner_tags inIOB format."""guid = 0for content in self.get_parsed_data(filepath):4 unmodified linescontent["TOKENS"],))labels = ["O"] * len(filtered_tokens)for entity_type in ["CLINENTITY",21 unmodified lineselse:labels[idx_token] = f"{entity_type}"yield guid, {"tokens": list(map(lambda tokens: tokens[2], filtered_tokens)),"ner_tags": labels,}guid += 129 unmodified lines303132333435363738396 unmodified lines464748495051521 unmodified line545556575859606162202 unmodified lines2652662672682692702712724 unmodified lines27727827928028128228328428521 unmodified lines30730830931031131231331431529 unmodified linesclass E3CConfig(datasets.BuilderConfig):"""BuilderConfig for E3C."""def __init__(self, **kwargs):"""BuilderConfig for E3C.Args:**kwargs: keyword arguments forwarded to super."""6 unmodified linesE3CConfig(name="e3c",version=VERSION,description="this is an implementation of the E3C dataset",),]1 unmodified line"""This method specifies the DatasetInfo which contains information and typings."""features = datasets.Features({"text": datasets.Value("string"),"tokens": datasets.Sequence(datasets.Value("string")),"tokens_offsets": datasets.Sequence(datasets.Sequence(datasets.Value("int32"))),"ner_tags": datasets.Sequence(datasets.features.ClassLabel(names=[202 unmodified linesArgs:filepath: The path to the folder containing the files to parse.Yields:an example containing four fields: the text, the annotations, the tokens offsets andthe sentences."""guid = 0for content in self.get_parsed_data(filepath):4 unmodified linescontent["TOKENS"],))tokens_offsets = [[token[0] - sentence[0], token[1] - sentence[0]] for token in filtered_tokens]labels = ["O"] * len(filtered_tokens)for entity_type in ["CLINENTITY",21 unmodified lineselse:labels[idx_token] = f"{entity_type}"yield guid, {"text": sentence[-1],"tokens": list(map(lambda tokens: tokens[2], filtered_tokens)),"ner_tags": labels,"tokens_offsets": tokens_offsets,}guid += 1
e3c.py+12-5