Datasets:
Upload 3 files
Browse files- .gitattributes +2 -0
- test.csv +3 -0
- train.csv +3 -0
- victorian_authorship.py +82 -0
.gitattributes
CHANGED
@@ -53,3 +53,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
56 |
+
test.csv filter=lfs diff=lfs merge=lfs -text
|
57 |
+
train.csv filter=lfs diff=lfs merge=lfs -text
|
test.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b8ebb429790d3639c17cd5f11c05b4fefb82ae51ae3ae14a6638d1b623630091
|
3 |
+
size 265585562
|
train.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:66136afe6b911e8777e934b5a92351f1ade17e9c5265f98d43f2f67048f3dffe
|
3 |
+
size 193572713
|
victorian_authorship.py
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Victorian."""
|
2 |
+
|
3 |
+
from typing import List
|
4 |
+
from functools import partial
|
5 |
+
|
6 |
+
import datasets
|
7 |
+
|
8 |
+
import pandas
|
9 |
+
|
10 |
+
|
11 |
+
VERSION = datasets.Version("1.0.0")
|
12 |
+
_ORIGINAL_FEATURE_NAMES = [
|
13 |
+
"text",
|
14 |
+
"author"
|
15 |
+
]
|
16 |
+
_BASE_FEATURE_NAMES = [
|
17 |
+
"text",
|
18 |
+
"author"
|
19 |
+
]
|
20 |
+
|
21 |
+
DESCRIPTION = "Victorian dataset from the Gungor thesis.\"."
|
22 |
+
_HOMEPAGE = "https://scholarworks.iupui.edu/server/api/core/bitstreams/708a9870-915e-4d59-b54d-938af563c196/content"
|
23 |
+
_URLS = ("https://scholarworks.iupui.edu/server/api/core/bitstreams/708a9870-915e-4d59-b54d-938af563c196/content")
|
24 |
+
_CITATION = """
|
25 |
+
@phdthesis{gungor2018benchmarking,
|
26 |
+
title={Benchmarking authorship attribution techniques using over a thousand books by fifty victorian era novelists},
|
27 |
+
author={Gungor, Abdulmecit},
|
28 |
+
year={2018},
|
29 |
+
school={Purdue University}
|
30 |
+
}"""
|
31 |
+
|
32 |
+
# Dataset info
|
33 |
+
urls_per_split = {
|
34 |
+
"train": "https://huggingface.co/datasets/mstz/victorian_authorship/raw/main/train.csv",
|
35 |
+
"test": "https://huggingface.co/datasets/mstz/victorian_authorship/raw/main/test.csv",
|
36 |
+
}
|
37 |
+
features_types_per_config = {
|
38 |
+
"authorship": {
|
39 |
+
"text": datasets.Value("string"),
|
40 |
+
"author": datasets.ClassLabel(num_classes=50)
|
41 |
+
}
|
42 |
+
}
|
43 |
+
features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
|
44 |
+
|
45 |
+
|
46 |
+
class VictorianConfig(datasets.BuilderConfig):
|
47 |
+
def __init__(self, **kwargs):
|
48 |
+
super(VictorianConfig, self).__init__(version=VERSION, **kwargs)
|
49 |
+
self.features = features_per_config[kwargs["name"]]
|
50 |
+
|
51 |
+
|
52 |
+
class Victorian(datasets.GeneratorBasedBuilder):
|
53 |
+
# dataset versions
|
54 |
+
DEFAULT_CONFIG = "authorship"
|
55 |
+
BUILDER_CONFIGS = [
|
56 |
+
VictorianConfig(name="authorship",
|
57 |
+
description="authorship"),
|
58 |
+
]
|
59 |
+
|
60 |
+
|
61 |
+
def _info(self):
|
62 |
+
info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
|
63 |
+
features=features_per_config[self.config.name])
|
64 |
+
|
65 |
+
return info
|
66 |
+
|
67 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
68 |
+
downloads = dl_manager.download_and_extract(urls_per_split)
|
69 |
+
|
70 |
+
return [
|
71 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
|
72 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloads["test"]})
|
73 |
+
]
|
74 |
+
|
75 |
+
def _generate_examples(self, filepath: str):
|
76 |
+
data = pandas.read_csv(filepath, header=None)
|
77 |
+
data.columns = _BASE_FEATURE_NAMES
|
78 |
+
|
79 |
+
for row_id, row in data.iterrows():
|
80 |
+
data_row = dict(row)
|
81 |
+
|
82 |
+
yield row_id, data_row
|