ruochenz commited on
Commit
c8b30cf
·
verified ·
1 Parent(s): eaf7c10

Upload folder using huggingface_hub

Browse files
Files changed (6) hide show
  1. .gitattributes +2 -0
  2. CroCoSum.py +106 -0
  3. data/src_docs.json +3 -0
  4. data/test.jsonl +0 -0
  5. data/train.jsonl +3 -0
  6. data/val.jsonl +0 -0
.gitattributes CHANGED
@@ -57,3 +57,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
60
+ data/src_docs.json filter=lfs diff=lfs merge=lfs -text
61
+ data/train.jsonl filter=lfs diff=lfs merge=lfs -text
CroCoSum.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+ import json
3
+ import jsonlines
4
+
5
+ logger = datasets.logging.get_logger(__name__)
6
+
7
+ _URL = "data/"
8
+ _URLS = {
9
+ "train": _URL + "train.jsonl",
10
+ "dev": _URL + "val.jsonl",
11
+ "test": _URL + "test.jsonl",
12
+ "html": _URL + "src_docs.json"
13
+ }
14
+ _VERSION = "0.0.1"
15
+ _DATASETNAME = "CroCoSum"
16
+
17
+ class SolidotSumConfig(datasets.BuilderConfig):
18
+ """BuilderConfig for SolidotSum."""
19
+
20
+ def __init__(self, **kwargs):
21
+ """BuilderConfig for SolidotSum.
22
+ Args:
23
+ **kwargs: keyword arguments forwarded to super.
24
+ """
25
+ super(SolidotSumConfig, self).__init__(**kwargs)
26
+
27
+
28
+ class SolidotSum(datasets.GeneratorBasedBuilder):
29
+ """SolidotSum: Summarization dataset from Solidot. """
30
+
31
+ BUILDER_CONFIGS = [
32
+ SolidotSumConfig(
33
+ name="plain_text",
34
+ version=datasets.Version(_VERSION, ""),
35
+ description="Dataset for Chinese-English Crosslingual Code-switched Summarization",
36
+ ),
37
+ ]
38
+
39
+ def _info(self):
40
+ return datasets.DatasetInfo(
41
+ description=_DATASETNAME,
42
+ features=datasets.Features(
43
+ {
44
+ "post_id": datasets.Value("string"),
45
+ "post_url": datasets.Value("string"),
46
+ "post_title": datasets.Value("string"),
47
+ "post_body": datasets.Value("string"),
48
+ "links": datasets.features.Sequence(
49
+ {
50
+ "link_id": datasets.Value("string"),
51
+ "link_url": datasets.Value("string"),
52
+ "link_title": datasets.Value("string"),
53
+ "link_body":datasets.Value("string")
54
+ }
55
+ ),
56
+ }
57
+ ),
58
+
59
+ )
60
+
61
+ def _split_generators(self, dl_manager):
62
+ downloaded_files = dl_manager.download_and_extract(_URLS)
63
+
64
+ return [
65
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"], "html_path": downloaded_files['html']}),
66
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"], "html_path": downloaded_files['html']}),
67
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"], "html_path": downloaded_files['html']}),
68
+ ]
69
+
70
+ def _generate_examples(self, filepath, html_path):
71
+ """This function returns the examples in the raw (text) form."""
72
+ logger.info("generating examples from = %s", filepath)
73
+ key = 0
74
+ with open(html_path) as f:
75
+ html_id_body_text_url = json.load(f)
76
+ with jsonlines.open(filepath) as f:
77
+ for post in f:
78
+ post_id = post['post_id']
79
+ post_title = post['post_title']
80
+ post_url = post['post_url']
81
+ post_body = post['post_text']
82
+ link_id = post['links']
83
+ link_urls = []
84
+ link_title = []
85
+ link_body = []
86
+
87
+ for link in post["links"]:
88
+ html_content = html_id_body_text_url[str(link)]
89
+ link_urls.append(html_content['url'])
90
+ link_title.append(html_content['title'])
91
+ link_body.append(html_content['body'])
92
+
93
+ yield key, {
94
+ "post_id": post_id,
95
+ "post_url": post_url,
96
+ "post_title": post_title,
97
+ "post_body":post_body,
98
+ "links": {
99
+ "link_id": link_id,
100
+ "link_url": link_urls,
101
+ "link_title": link_title,
102
+ "link_body": link_body
103
+ },
104
+ }
105
+ key += 1
106
+
data/src_docs.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e81df2675e2ce3e76de2c93dbe46b6843941040344608bb85d017a33b3cb9319
3
+ size 128484366
data/test.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/train.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7bddf8ae3bf86e4d988dba0431b3be0ef57105fa7da1117784094d3fbc7fde4c
3
+ size 21657141
data/val.jsonl ADDED
The diff for this file is too large to render. See raw diff