chore: regenerate parquets from upstream XML source
Browse filesConversion script now loads corpus XML directly from the upstream
repository URL instead of requiring local files. Parquets regenerated
from authoritative source to pick up any minor differences.
causal-candidate-extraction/train.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4ea0abb55b00effbeffde37bb96b77198fa6d4ea49b87dd09e48cf366efd0d64
|
| 3 |
+
size 336015
|
causality-detection/test.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ff47b4238f1ce31c93eadf27930531e9f6960cd5d9bcf5e5e35a6e1093a20fe7
|
| 3 |
+
size 59931
|
causality-detection/train.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8b9e398fc93636c08ca1d1f98a978aee2541de298596a034a3579585d497e00b
|
| 3 |
+
size 326546
|
causality-identification/test.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f07b19d9a198d4e72381ce6b163d9c767c4a1dac9ab8faaa0059d9796011df72
|
| 3 |
+
size 69416
|
causality-identification/train.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5af37fb089407e1f9a8d895f00c90055f0491fa996c663ab49649021b1b2d608
|
| 3 |
+
size 372251
|
conversion_script.py
CHANGED
|
@@ -2,6 +2,9 @@
|
|
| 2 |
|
| 3 |
"""
|
| 4 |
Run this script as ./conversion_script.py to convert the SCITE files to HF-compatible parquet files.
|
|
|
|
|
|
|
|
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
import re
|
|
@@ -9,11 +12,15 @@ from typing import Literal
|
|
| 9 |
|
| 10 |
import pandas as pd
|
| 11 |
|
|
|
|
| 12 |
|
| 13 |
Split = Literal["train", "test"]
|
| 14 |
|
|
|
|
|
|
|
|
|
|
| 15 |
def convert_for_causality_detection(split: Split) -> None:
|
| 16 |
-
df =
|
| 17 |
df["label"] = df["label"].apply(lambda x: 0 if x == "Non-Causal" else 1)
|
| 18 |
df["text"] = df["sentence"].apply(lambda x: re.sub(r'</?e\d+>', "", x))
|
| 19 |
df["index"] = df["id"].apply(lambda x: f"scite_{split}_{x}")
|
|
@@ -52,7 +59,7 @@ def convert_for_causal_candidate_extraction(split: Split) -> None:
|
|
| 52 |
|
| 53 |
return "".join(plain_chars), spans
|
| 54 |
|
| 55 |
-
df =
|
| 56 |
# Reuse the relation parsing from convert_for_causality_identification
|
| 57 |
def map_label(label: str) -> list:
|
| 58 |
if label == "Non-Causal":
|
|
@@ -81,7 +88,7 @@ def convert_for_causality_identification(split: Split) -> None:
|
|
| 81 |
left, right = t.strip('()').split(',')
|
| 82 |
tmp.append({"relationship": 1, "first": left, "second": right})
|
| 83 |
return tmp
|
| 84 |
-
df =
|
| 85 |
df["relations"] = df["label"].apply(map_label)
|
| 86 |
df["text"] = df["sentence"]
|
| 87 |
df["index"] = df["id"].apply(lambda x: f"scite_{split}_{x}")
|
|
|
|
| 2 |
|
| 3 |
"""
|
| 4 |
Run this script as ./conversion_script.py to convert the SCITE files to HF-compatible parquet files.
|
| 5 |
+
|
| 6 |
+
Source data is loaded directly from the upstream repository:
|
| 7 |
+
https://github.com/Das-Boot/scite/tree/master/corpus
|
| 8 |
"""
|
| 9 |
|
| 10 |
import re
|
|
|
|
| 12 |
|
| 13 |
import pandas as pd
|
| 14 |
|
| 15 |
+
_BASE_URL = "https://raw.githubusercontent.com/Das-Boot/scite/master/corpus"
|
| 16 |
|
| 17 |
Split = Literal["train", "test"]
|
| 18 |
|
| 19 |
+
def _read_xml(split: Split, **kwargs) -> pd.DataFrame:
|
| 20 |
+
return pd.read_xml(f"{_BASE_URL}/{split}-corpus.xml", **kwargs)
|
| 21 |
+
|
| 22 |
def convert_for_causality_detection(split: Split) -> None:
|
| 23 |
+
df = _read_xml(split)
|
| 24 |
df["label"] = df["label"].apply(lambda x: 0 if x == "Non-Causal" else 1)
|
| 25 |
df["text"] = df["sentence"].apply(lambda x: re.sub(r'</?e\d+>', "", x))
|
| 26 |
df["index"] = df["id"].apply(lambda x: f"scite_{split}_{x}")
|
|
|
|
| 59 |
|
| 60 |
return "".join(plain_chars), spans
|
| 61 |
|
| 62 |
+
df = _read_xml(split, dtype_backend="pyarrow")
|
| 63 |
# Reuse the relation parsing from convert_for_causality_identification
|
| 64 |
def map_label(label: str) -> list:
|
| 65 |
if label == "Non-Causal":
|
|
|
|
| 88 |
left, right = t.strip('()').split(',')
|
| 89 |
tmp.append({"relationship": 1, "first": left, "second": right})
|
| 90 |
return tmp
|
| 91 |
+
df = _read_xml(split, dtype_backend="pyarrow")
|
| 92 |
df["relations"] = df["label"].apply(map_label)
|
| 93 |
df["text"] = df["sentence"]
|
| 94 |
df["index"] = df["id"].apply(lambda x: f"scite_{split}_{x}")
|