Datasets:
Tasks:
Token Classification
Sub-tasks:
named-entity-recognition
Languages:
English
Size:
100K<n<1M
License:
napsternxg
commited on
Commit
•
946738b
1
Parent(s):
3a7e6d8
Create nyt_ingredients.py
Browse files- nyt_ingredients.py +21 -16
nyt_ingredients.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
|
2 |
"""New York Times Ingredient Phrase Tagger Dataset"""
|
3 |
|
4 |
|
@@ -12,7 +11,7 @@ _CITATION = """\
|
|
12 |
@misc{nytimesTaggedIngredients,
|
13 |
author = {Erica Greene and Adam Mckaig},
|
14 |
title = {{O}ur {T}agged {I}ngredients {D}ata is {N}ow on {G}it{H}ub --- archive.nytimes.com},
|
15 |
-
howpublished = {
|
16 |
year = {},
|
17 |
note = {[Accessed 03-10-2023]},
|
18 |
}
|
@@ -42,6 +41,7 @@ _URL = "https://github.com/nytimes/ingredient-phrase-tagger"
|
|
42 |
|
43 |
import json
|
44 |
|
|
|
45 |
class NYTIngedientsConfig(datasets.BuilderConfig):
|
46 |
"""The NYTIngedients Dataset."""
|
47 |
|
@@ -58,7 +58,9 @@ class NYTIngedients(datasets.GeneratorBasedBuilder):
|
|
58 |
|
59 |
BUILDER_CONFIGS = [
|
60 |
NYTIngedientsConfig(
|
61 |
-
name="nyt-ingredients",
|
|
|
|
|
62 |
),
|
63 |
]
|
64 |
|
@@ -77,17 +79,17 @@ class NYTIngedients(datasets.GeneratorBasedBuilder):
|
|
77 |
"label": datasets.Sequence(
|
78 |
datasets.features.ClassLabel(
|
79 |
names=[
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
]
|
92 |
)
|
93 |
),
|
@@ -101,11 +103,14 @@ class NYTIngedients(datasets.GeneratorBasedBuilder):
|
|
101 |
def _split_generators(self, dl_manager):
|
102 |
"""Returns SplitGenerators."""
|
103 |
return [
|
104 |
-
datasets.SplitGenerator(
|
|
|
|
|
|
|
105 |
]
|
106 |
|
107 |
def _generate_examples(self, filepath):
|
108 |
logger.info("⏳ Generating examples from = %s", filepath)
|
109 |
with open(filepath, encoding="utf-8") as fp:
|
110 |
for i, line in enumerate(fp):
|
111 |
-
|
|
|
|
|
1 |
"""New York Times Ingredient Phrase Tagger Dataset"""
|
2 |
|
3 |
|
|
|
11 |
@misc{nytimesTaggedIngredients,
|
12 |
author = {Erica Greene and Adam Mckaig},
|
13 |
title = {{O}ur {T}agged {I}ngredients {D}ata is {N}ow on {G}it{H}ub --- archive.nytimes.com},
|
14 |
+
howpublished = {\\url{https://archive.nytimes.com/open.blogs.nytimes.com/2016/04/27/structured-ingredients-data-tagging/}},
|
15 |
year = {},
|
16 |
note = {[Accessed 03-10-2023]},
|
17 |
}
|
|
|
41 |
|
42 |
import json
|
43 |
|
44 |
+
|
45 |
class NYTIngedientsConfig(datasets.BuilderConfig):
|
46 |
"""The NYTIngedients Dataset."""
|
47 |
|
|
|
58 |
|
59 |
BUILDER_CONFIGS = [
|
60 |
NYTIngedientsConfig(
|
61 |
+
name="nyt-ingredients",
|
62 |
+
version=datasets.Version("1.0.0"),
|
63 |
+
description="The NYTIngedients Dataset",
|
64 |
),
|
65 |
]
|
66 |
|
|
|
79 |
"label": datasets.Sequence(
|
80 |
datasets.features.ClassLabel(
|
81 |
names=[
|
82 |
+
"O",
|
83 |
+
"B-COMMENT",
|
84 |
+
"I-COMMENT",
|
85 |
+
"B-NAME",
|
86 |
+
"I-NAME",
|
87 |
+
"B-RANGE_END",
|
88 |
+
"I-RANGE_END",
|
89 |
+
"B-QTY",
|
90 |
+
"I-QTY",
|
91 |
+
"B-UNIT",
|
92 |
+
"I-UNIT",
|
93 |
]
|
94 |
)
|
95 |
),
|
|
|
103 |
def _split_generators(self, dl_manager):
|
104 |
"""Returns SplitGenerators."""
|
105 |
return [
|
106 |
+
datasets.SplitGenerator(
|
107 |
+
name=datasets.Split.TRAIN,
|
108 |
+
gen_kwargs={"filepath": "nyt-ingredients.crf.jsonl"},
|
109 |
+
),
|
110 |
]
|
111 |
|
112 |
def _generate_examples(self, filepath):
|
113 |
logger.info("⏳ Generating examples from = %s", filepath)
|
114 |
with open(filepath, encoding="utf-8") as fp:
|
115 |
for i, line in enumerate(fp):
|
116 |
+
yield i, json.loads(line)
|