ruanchaves commited on
Commit
10b6ef6
1 Parent(s): ad00853

Upload jhotdraw.py

Browse files
Files changed (1) hide show
  1. jhotdraw.py +63 -0
jhotdraw.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """BT11"""
2
+
3
+ import datasets
4
+ import pandas as pd
5
+ from collections import deque
6
+
7
+ _CITATION = """
8
+ @inproceedings{li2018helpful,
9
+ title={Helpful or Not? An investigation on the feasibility of identifier splitting via CNN-BiLSTM-CRF.},
10
+ author={Li, Jiechu and Du, Qingfeng and Shi, Kun and He, Yu and Wang, Xin and Xu, Jincheng},
11
+ booktitle={SEKE},
12
+ pages={175--174},
13
+ year={2018}
14
+ }
15
+ """
16
+
17
+ _DESCRIPTION = """
18
+ In programming languages, identifiers are tokens (also called symbols) which name language entities.
19
+ Some of the kinds of entities an identifier might denote include variables, types, labels, subroutines, and packages.
20
+
21
+ Jhotdraw is a dataset for identifier segmentation,
22
+ i.e. the task of adding spaces between the words on a identifier.
23
+ """
24
+ _URL = "https://raw.githubusercontent.com/ruanchaves/hashformers/master/datasets/jhotdraw.txt"
25
+
26
+ class Jhotdraw(datasets.GeneratorBasedBuilder):
27
+
28
+ VERSION = datasets.Version("1.0.0")
29
+
30
+ def _info(self):
31
+ return datasets.DatasetInfo(
32
+ description=_DESCRIPTION,
33
+ features=datasets.Features(
34
+ {
35
+ "index": datasets.Value("int32"),
36
+ "identifier": datasets.Value("string"),
37
+ "segmentation": datasets.Value("string")
38
+ }
39
+ ),
40
+ supervised_keys=None,
41
+ homepage="",
42
+ citation=_CITATION,
43
+ )
44
+
45
+ def _split_generators(self, dl_manager):
46
+ downloaded_files = dl_manager.download(_URL)
47
+ return [
48
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files}),
49
+ ]
50
+
51
+ def _generate_examples(self, filepath):
52
+
53
+ with open(filepath, "r") as f:
54
+
55
+ for idx, line in enumerate(f):
56
+ fields = line.split(":")
57
+ identifier = fields[0].strip()
58
+ segmentation = fields[1].strip()
59
+ yield idx, {
60
+ "index": idx,
61
+ "identifier": identifier,
62
+ "segmentation": segmentation
63
+ }