Yiran Guo commited on
Commit
744397b
1 Parent(s): 1d16525

Add dataset files and load script

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. README.md +49 -3
  3. data.csv +3 -0
  4. privacy_detection.py +106 -0
.gitattributes CHANGED
@@ -53,3 +53,4 @@ 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
+ data.csv filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,6 +1,52 @@
1
  ---
2
- task_categories:
3
- - token-classification
4
  language:
5
  - zh
6
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
 
 
2
  language:
3
  - zh
4
+ task_categories:
5
+ - token-classification
6
+ dataset_info:
7
+ config_name: privacy_detection
8
+ features:
9
+ - name: id
10
+ dtype: string
11
+ - name: tokens
12
+ sequence: string
13
+ - name: ner_tags
14
+ sequence:
15
+ class_label:
16
+ names:
17
+ '0': O
18
+ '1': B-position
19
+ '2': I-position
20
+ '3': B-name
21
+ '4': I-name
22
+ '5': B-movie
23
+ '6': I-movie
24
+ '7': B-organization
25
+ '8': I-organization
26
+ '9': B-company
27
+ '10': I-company
28
+ '11': B-book
29
+ '12': I-book
30
+ '13': B-address
31
+ '14': I-address
32
+ '15': B-scene
33
+ '16': I-scene
34
+ '17': B-mobile
35
+ '18': I-mobile
36
+ '19': B-email
37
+ '20': I-email
38
+ '21': B-game
39
+ '22': I-game
40
+ '23': B-government
41
+ '24': I-government
42
+ '25': B-QQ
43
+ '26': I-QQ
44
+ '27': B-vx
45
+ '28': I-vx
46
+ splits:
47
+ - name: train
48
+ num_bytes: 4899635
49
+ num_examples: 2515
50
+ download_size: 3290405
51
+ dataset_size: 4899635
52
+ ---
data.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:690245ea213cab30e199ffd9076ac6c8762665573b19c37e9007bcdda8f24c36
3
+ size 3290405
privacy_detection.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ import datasets
3
+ import pandas as pd
4
+
5
+
6
+ logger = datasets.logging.get_logger(__name__)
7
+
8
+
9
+ _DESCRIPTION = """\
10
+ privacy detection dataset, which includes the following categories of privacy information: [position, name, movie, organization, company, book, address, scene, mobile, email, game, government, QQ, vx].
11
+ The dataset consists of 3 columns. The first column is id, the second column is the list of text characters, and the third column is the list of privacy entity annotations. The entity annotation format is such that each entity's leading character is labeled as B-TYPE, the internal characters of the entity are labeled as I-TYPE, and the character is labeled O if it does not belong to any entity.
12
+ For more details see: https://www.datafountain.cn/competitions/472.
13
+ """
14
+
15
+ _URL = "data.csv"
16
+
17
+
18
+ class PrivacyDetectionConfig(datasets.BuilderConfig):
19
+ def __init__(self, **kwargs):
20
+ super(PrivacyDetectionConfig, self).__init__(**kwargs)
21
+
22
+
23
+ class PrivacyDectection(datasets.GeneratorBasedBuilder):
24
+ """PrivacyDectection dataset."""
25
+
26
+ BUILDER_CONFIGS = [
27
+ PrivacyDetectionConfig(
28
+ name="privacy_detection",
29
+ version=datasets.Version("1.0.0"),
30
+ description="privacy detection dataset",
31
+ ),
32
+ ]
33
+
34
+ def _info(self):
35
+ return datasets.DatasetInfo(
36
+ description=_DESCRIPTION,
37
+ features=datasets.Features(
38
+ {
39
+ "id": datasets.Value("string"),
40
+ "tokens": datasets.Sequence(datasets.Value("string")),
41
+ "ner_tags": datasets.Sequence(
42
+ datasets.features.ClassLabel(
43
+ names=[
44
+ "O",
45
+ "B-position",
46
+ "I-position",
47
+ "B-name",
48
+ "I-name",
49
+ "B-movie",
50
+ "I-movie",
51
+ "B-organization",
52
+ "I-organization",
53
+ "B-company",
54
+ "I-company",
55
+ "B-book",
56
+ "I-book",
57
+ "B-address",
58
+ "I-address",
59
+ "B-scene",
60
+ "I-scene",
61
+ "B-mobile",
62
+ "I-mobile",
63
+ "B-email",
64
+ "I-email",
65
+ "B-game",
66
+ "I-game",
67
+ "B-government",
68
+ "I-government",
69
+ "B-QQ",
70
+ "I-QQ",
71
+ "B-vx",
72
+ "I-vx",
73
+ ]
74
+ )
75
+ ),
76
+ }
77
+ ),
78
+ supervised_keys=None,
79
+ homepage="https://www.datafountain.cn/competitions/472",
80
+ )
81
+
82
+ def _split_generators(self, dl_manager):
83
+ """Returns SplitGenerators."""
84
+ downloaded_file = dl_manager.download_and_extract(_URL)
85
+ data_files = {
86
+ "train": downloaded_file,
87
+ }
88
+
89
+ return [
90
+ datasets.SplitGenerator(
91
+ name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_files["train"]}
92
+ )
93
+ ]
94
+
95
+ def _generate_examples(self, filepath):
96
+ logger.info("⏳ Generating examples from = %s", filepath)
97
+ data = pd.read_csv(filepath)
98
+ for _, row in data.iterrows():
99
+ id_ = row["id"]
100
+ tokens = eval(row["tokens"])
101
+ ner_tags = eval(row["ner_tags"])
102
+ yield id_, {
103
+ "id": id_,
104
+ "tokens": tokens,
105
+ "ner_tags": ner_tags,
106
+ }