Commit
•
c896074
1
Parent(s):
28f9970
Rename variable id to guid
Browse files
twadrl.py
CHANGED
@@ -125,10 +125,10 @@ class TwADRL(datasets.GeneratorBasedBuilder):
|
|
125 |
def _generate_examples(self, filepath, split_id):
|
126 |
with open(filepath, "r", encoding="latin-1") as f:
|
127 |
for i, line in enumerate(f):
|
128 |
-
|
129 |
cui, medical_concept, social_media_text = line.strip().split("\t")
|
130 |
if self.config.schema == "source":
|
131 |
-
yield
|
132 |
"cui": cui,
|
133 |
"medical_concept": medical_concept,
|
134 |
"social_media_text": social_media_text,
|
@@ -136,12 +136,12 @@ class TwADRL(datasets.GeneratorBasedBuilder):
|
|
136 |
elif self.config.schema == "bigbio_kb":
|
137 |
text_type = "social_media_text"
|
138 |
offset = (0, len(social_media_text))
|
139 |
-
yield
|
140 |
-
"id":
|
141 |
-
"document_id":
|
142 |
"passages": [
|
143 |
{
|
144 |
-
"id": f"{
|
145 |
"type": text_type,
|
146 |
"text": [social_media_text],
|
147 |
"offsets": [offset],
|
@@ -149,7 +149,7 @@ class TwADRL(datasets.GeneratorBasedBuilder):
|
|
149 |
],
|
150 |
"entities": [
|
151 |
{
|
152 |
-
"id": f"{
|
153 |
"type": text_type,
|
154 |
"text": [social_media_text],
|
155 |
"offsets": [offset],
|
|
|
125 |
def _generate_examples(self, filepath, split_id):
|
126 |
with open(filepath, "r", encoding="latin-1") as f:
|
127 |
for i, line in enumerate(f):
|
128 |
+
guid = f"{split_id}_{i}"
|
129 |
cui, medical_concept, social_media_text = line.strip().split("\t")
|
130 |
if self.config.schema == "source":
|
131 |
+
yield guid, {
|
132 |
"cui": cui,
|
133 |
"medical_concept": medical_concept,
|
134 |
"social_media_text": social_media_text,
|
|
|
136 |
elif self.config.schema == "bigbio_kb":
|
137 |
text_type = "social_media_text"
|
138 |
offset = (0, len(social_media_text))
|
139 |
+
yield guid, {
|
140 |
+
"id": guid,
|
141 |
+
"document_id": guid,
|
142 |
"passages": [
|
143 |
{
|
144 |
+
"id": f"{guid}_passage",
|
145 |
"type": text_type,
|
146 |
"text": [social_media_text],
|
147 |
"offsets": [offset],
|
|
|
149 |
],
|
150 |
"entities": [
|
151 |
{
|
152 |
+
"id": f"{guid}_entity",
|
153 |
"type": text_type,
|
154 |
"text": [social_media_text],
|
155 |
"offsets": [offset],
|