asahi417 commited on
Commit
79a7199
1 Parent(s): 066eb10
README.md ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license:
5
+ - other
6
+ multilinguality:
7
+ - monolingual
8
+ size_categories:
9
+ - 10K<n<100K
10
+ task_categories:
11
+ - token-classification
12
+ task_ids:
13
+ - named-entity-recognition
14
+ pretty_name: MIT Restaurant
15
+ ---
16
+
17
+ # Dataset Card for "tner/mit_restaurant"
18
+
19
+ ## Dataset Description
20
+
21
+ - **Repository:** [T-NER](https://github.com/asahi417/tner)
22
+ - **Paper:** [https://aclanthology.org/U15-1010.pdf](https://aclanthology.org/U15-1010.pdf)
23
+ - **Dataset:** MIT restaurant
24
+ - **Domain:** Restaurant
25
+ - **Number of Entity:** 8
26
+
27
+ ### Dataset Summary
28
+ MIT Restaurant NER dataset formatted in a part of [TNER](https://github.com/asahi417/tner) project.
29
+
30
+ - Entity Types: `Rating`, `Amenity`, `Location`, `Restaurant_Name`, `Price`, `Hours`, `Dish`, `Cuisine`.
31
+
32
+ ## Dataset Structure
33
+
34
+ ### Data Instances
35
+ An example of `train` looks as follows.
36
+
37
+ ```
38
+ {
39
+ "tags": [0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
40
+ "tokens": ["1", ".", "1", ".", "4", "Borrower", "engages", "in", "criminal", "conduct", "or", "is", "involved", "in", "criminal", "activities", ";"]
41
+ }
42
+ ```
43
+
44
+ ### Label ID
45
+ The label2id dictionary can be found at [here](https://huggingface.co/datasets/tner/mit_restaurant/raw/main/dataset/label.json).
46
+ ```python
47
+ {
48
+ "O": 0,
49
+ "B-Rating": 1,
50
+ "I-Rating": 2,
51
+ "B-Amenity": 3,
52
+ "I-Amenity": 4,
53
+ "B-Location": 5,
54
+ "I-Location": 6,
55
+ "B-Restaurant_Name": 7,
56
+ "I-Restaurant_Name": 8,
57
+ "B-Price": 9,
58
+ "B-Hours": 10,
59
+ "I-Hours": 11,
60
+ "B-Dish": 12,
61
+ "I-Dish": 13,
62
+ "B-Cuisine": 14,
63
+ "I-Price": 15,
64
+ "I-Cuisine": 16
65
+ }
66
+ ```
67
+
68
+ ### Data Splits
69
+
70
+ | name |train|validation|test|
71
+ |---------|----:|---------:|---:|
72
+ |mit_restaurant |6899 | 759| 1520|
dataset/label.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"O": 0, "B-Rating": 1, "I-Rating": 2, "B-Amenity": 3, "I-Amenity": 4, "B-Location": 5, "I-Location": 6, "B-Restaurant_Name": 7, "I-Restaurant_Name": 8, "B-Price": 9, "B-Hours": 10, "I-Hours": 11, "B-Dish": 12, "I-Dish": 13, "B-Cuisine": 14, "I-Price": 15, "I-Cuisine": 16}
dataset/test.json ADDED
The diff for this file is too large to render. See raw diff
 
dataset/train.json ADDED
The diff for this file is too large to render. See raw diff
 
dataset/valid.json ADDED
The diff for this file is too large to render. See raw diff
 
mit_restaurant.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ NER dataset compiled by T-NER library https://github.com/asahi417/tner/tree/master/tner """
2
+ import json
3
+ from itertools import chain
4
+ import datasets
5
+
6
+ logger = datasets.logging.get_logger(__name__)
7
+ _DESCRIPTION = """[mit_restaurant NER dataset](https://groups.csail.mit.edu/sls/downloads/)"""
8
+ _NAME = "mit_restaurant"
9
+ _VERSION = "1.0.0"
10
+
11
+ _HOME_PAGE = "https://github.com/asahi417/tner"
12
+ _URL = f'https://huggingface.co/datasets/tner/{_NAME}/raw/main/dataset'
13
+ _URLS = {
14
+ str(datasets.Split.TEST): [f'{_URL}/test.json'],
15
+ str(datasets.Split.TRAIN): [f'{_URL}/train.json'],
16
+ str(datasets.Split.VALIDATION): [f'{_URL}/valid.json'],
17
+ }
18
+
19
+
20
+ class MITRestaurantConfig(datasets.BuilderConfig):
21
+ """BuilderConfig"""
22
+
23
+ def __init__(self, **kwargs):
24
+ """BuilderConfig.
25
+
26
+ Args:
27
+ **kwargs: keyword arguments forwarded to super.
28
+ """
29
+ super(MITRestaurantConfig, self).__init__(**kwargs)
30
+
31
+
32
+ class MITRestaurant(datasets.GeneratorBasedBuilder):
33
+ """Dataset."""
34
+
35
+ BUILDER_CONFIGS = [
36
+ MITRestaurantConfig(name=_NAME, version=datasets.Version(_VERSION), description=_DESCRIPTION),
37
+ ]
38
+
39
+ def _split_generators(self, dl_manager):
40
+ downloaded_file = dl_manager.download_and_extract(_URLS)
41
+ return [datasets.SplitGenerator(name=i, gen_kwargs={"filepaths": downloaded_file[str(i)]})
42
+ for i in [datasets.Split.TRAIN, datasets.Split.VALIDATION, datasets.Split.TEST]]
43
+
44
+ def _generate_examples(self, filepaths):
45
+ _key = 0
46
+ for filepath in filepaths:
47
+ logger.info(f"generating examples from = {filepath}")
48
+ with open(filepath, encoding="utf-8") as f:
49
+ _list = [i for i in f.read().split('\n') if len(i) > 0]
50
+ for i in _list:
51
+ data = json.loads(i)
52
+ yield _key, data
53
+ _key += 1
54
+
55
+ def _info(self):
56
+ return datasets.DatasetInfo(
57
+ description=_DESCRIPTION,
58
+ features=datasets.Features(
59
+ {
60
+ "tokens": datasets.Sequence(datasets.Value("string")),
61
+ "tags": datasets.Sequence(datasets.Value("int32")),
62
+ }
63
+ ),
64
+ supervised_keys=None,
65
+ homepage=_HOME_PAGE,
66
+ citation=_CITATION,
67
+ )