Datasets:
Commit
·
58a9aa1
1
Parent(s):
31bf493
Update sts-sohu2021.py
Browse files- sts-sohu2021.py +6 -6
sts-sohu2021.py
CHANGED
|
@@ -19,7 +19,7 @@ _DESCRIPTION = """\
|
|
| 19 |
2021搜狐校园文本匹配算法大赛数据集
|
| 20 |
"""
|
| 21 |
|
| 22 |
-
_DATA_URL = "https://huggingface.co/datasets/shibing624/sts-sohu2021/resolve/main
|
| 23 |
|
| 24 |
|
| 25 |
class Sohu(datasets.GeneratorBasedBuilder):
|
|
@@ -76,24 +76,24 @@ class Sohu(datasets.GeneratorBasedBuilder):
|
|
| 76 |
)
|
| 77 |
|
| 78 |
def _split_generators(self, dl_manager):
|
| 79 |
-
|
| 80 |
-
|
|
|
|
| 81 |
return [
|
| 82 |
-
|
| 83 |
datasets.SplitGenerator(
|
| 84 |
name=datasets.Split.TRAIN, gen_kwargs={"filepath": dl_file}
|
| 85 |
),
|
| 86 |
]
|
| 87 |
|
| 88 |
def _generate_examples(self, filepath):
|
| 89 |
-
"""This function returns the examples in the raw (
|
| 90 |
id = 0
|
| 91 |
if isinstance(filepath, str):
|
| 92 |
filepath = [filepath]
|
| 93 |
for file in filepath:
|
| 94 |
with open(file, encoding="utf-8") as f:
|
| 95 |
for key, row in enumerate(f):
|
| 96 |
-
data = json.loads(row)
|
| 97 |
yield id, {
|
| 98 |
"sentence1": data["sentence1"],
|
| 99 |
"sentence2": data["sentence2"],
|
|
|
|
| 19 |
2021搜狐校园文本匹配算法大赛数据集
|
| 20 |
"""
|
| 21 |
|
| 22 |
+
_DATA_URL = "https://huggingface.co/datasets/shibing624/sts-sohu2021/resolve/main"
|
| 23 |
|
| 24 |
|
| 25 |
class Sohu(datasets.GeneratorBasedBuilder):
|
|
|
|
| 76 |
)
|
| 77 |
|
| 78 |
def _split_generators(self, dl_manager):
|
| 79 |
+
# https://huggingface.co/datasets/shibing624/sts-sohu2021/resolve/main/dda.jsonl
|
| 80 |
+
file_path = f"{_DATA_URL}/{self.config.name}.jsonl"
|
| 81 |
+
dl_file = dl_manager.download_and_extract(file_path)
|
| 82 |
return [
|
|
|
|
| 83 |
datasets.SplitGenerator(
|
| 84 |
name=datasets.Split.TRAIN, gen_kwargs={"filepath": dl_file}
|
| 85 |
),
|
| 86 |
]
|
| 87 |
|
| 88 |
def _generate_examples(self, filepath):
|
| 89 |
+
"""This function returns the examples in the raw (jsonl) form."""
|
| 90 |
id = 0
|
| 91 |
if isinstance(filepath, str):
|
| 92 |
filepath = [filepath]
|
| 93 |
for file in filepath:
|
| 94 |
with open(file, encoding="utf-8") as f:
|
| 95 |
for key, row in enumerate(f):
|
| 96 |
+
data = json.loads(row.strip())
|
| 97 |
yield id, {
|
| 98 |
"sentence1": data["sentence1"],
|
| 99 |
"sentence2": data["sentence2"],
|