Update ai_hub_summarization.py
Browse files- ai_hub_summarization.py +14 -19
ai_hub_summarization.py
CHANGED
@@ -1,13 +1,15 @@
|
|
1 |
-
import
|
|
|
2 |
import datasets
|
|
|
3 |
|
4 |
_CITATION = """"""
|
5 |
_DESCRIPTION = """"""
|
6 |
_LICENSE = "CC-BY-SA-4.0"
|
7 |
# _URL = "https://github.com/boostcampaitech2/data-annotation-nlp-level3-nlp-14"
|
8 |
_DATA_URLS = {
|
9 |
-
"train": "https://huggingface.co/datasets/raki-1203/ai_hub_summarization/resolve/main/
|
10 |
-
"dev": "https://huggingface.co/datasets/raki-1203/ai_hub_summarization/resolve/main/
|
11 |
}
|
12 |
|
13 |
_VERSION = "0.0.0"
|
@@ -36,11 +38,9 @@ class AiHubSummarization(datasets.GeneratorBasedBuilder):
|
|
36 |
{
|
37 |
"data_name": datasets.Value("string"),
|
38 |
"doc_id": datasets.Value("string"),
|
39 |
-
"passage_id": datasets.Value("string"),
|
40 |
"doc_name": datasets.Value("string"),
|
41 |
"passage": datasets.Value("string"),
|
42 |
"abstract_summary": datasets.Value("string"),
|
43 |
-
"extract_summary": datasets.Value("string"),
|
44 |
}
|
45 |
),
|
46 |
license=_LICENSE,
|
@@ -70,21 +70,16 @@ class AiHubSummarization(datasets.GeneratorBasedBuilder):
|
|
70 |
|
71 |
def _generate_examples(self, data_file: str, split: str):
|
72 |
""" Yields examples. """
|
73 |
-
with open(data_file, newline='', encoding="UTF-8") as
|
74 |
-
|
75 |
-
|
76 |
-
idx
|
77 |
-
for row in reader:
|
78 |
-
if idx == 0:
|
79 |
-
continue
|
80 |
features = {
|
81 |
-
"data_name": row[
|
82 |
-
"doc_id": row[
|
83 |
-
"
|
84 |
-
"
|
85 |
-
"
|
86 |
-
"abstract_summary": row[5],
|
87 |
-
"extract_summary": row[6],
|
88 |
}
|
89 |
yield idx, features
|
90 |
idx += 1
|
|
|
1 |
+
import json
|
2 |
+
|
3 |
import datasets
|
4 |
+
import pandas as pd
|
5 |
|
6 |
_CITATION = """"""
|
7 |
_DESCRIPTION = """"""
|
8 |
_LICENSE = "CC-BY-SA-4.0"
|
9 |
# _URL = "https://github.com/boostcampaitech2/data-annotation-nlp-level3-nlp-14"
|
10 |
_DATA_URLS = {
|
11 |
+
"train": "https://huggingface.co/datasets/raki-1203/ai_hub_summarization/resolve/main/train_dict.json",
|
12 |
+
"dev": "https://huggingface.co/datasets/raki-1203/ai_hub_summarization/resolve/main/valid_dict.json",
|
13 |
}
|
14 |
|
15 |
_VERSION = "0.0.0"
|
|
|
38 |
{
|
39 |
"data_name": datasets.Value("string"),
|
40 |
"doc_id": datasets.Value("string"),
|
|
|
41 |
"doc_name": datasets.Value("string"),
|
42 |
"passage": datasets.Value("string"),
|
43 |
"abstract_summary": datasets.Value("string"),
|
|
|
44 |
}
|
45 |
),
|
46 |
license=_LICENSE,
|
|
|
70 |
|
71 |
def _generate_examples(self, data_file: str, split: str):
|
72 |
""" Yields examples. """
|
73 |
+
with open(data_file, newline='', encoding="UTF-8") as f:
|
74 |
+
json_file = json.load(f, delimiter='\t')
|
75 |
+
df = pd.DataFrame(json_file)
|
76 |
+
for idx, row in df.iterrows():
|
|
|
|
|
|
|
77 |
features = {
|
78 |
+
"data_name": row['data_name'],
|
79 |
+
"doc_id": row['doc_id'],
|
80 |
+
"doc_name": row['doc_name'],
|
81 |
+
"passage": row['passage'],
|
82 |
+
"abstract_summary": row['abstract_summary'],
|
|
|
|
|
83 |
}
|
84 |
yield idx, features
|
85 |
idx += 1
|