Commit ·
2fd4750
1
Parent(s): da0244b
generation file
Browse files- generate_split.py +19 -0
generate_split.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datasets import load_dataset
|
| 2 |
+
dataset = load_dataset("allenai/s2orc",
|
| 3 |
+
split="train[:1%]",
|
| 4 |
+
num_proc=20)
|
| 5 |
+
import spacy
|
| 6 |
+
import spacy_fastlang
|
| 7 |
+
nlp = spacy.load("en_core_web_sm")
|
| 8 |
+
nlp.disable_pipes(nlp.pipe_names)
|
| 9 |
+
nlp.add_pipe("language_detector")
|
| 10 |
+
def has_abstract(example):
|
| 11 |
+
|
| 12 |
+
if "paperAbstract" in example.keys() and example["paperAbstract"] is not None \
|
| 13 |
+
and len(example["paperAbstract"].split())>5:
|
| 14 |
+
doc = nlp(example["paperAbstract"])
|
| 15 |
+
if doc._.language == 'en' and doc._.language_score >= 0.8:
|
| 16 |
+
return True
|
| 17 |
+
return False
|
| 18 |
+
dataset_sub = dataset.filter(has_abstract)
|
| 19 |
+
dataset_sub.push_to_hub("leminda-ai/s2orc_small",split='train',token='XXXXXXXXXXXX')
|