napsternxg commited on
Commit
43686b3
1 Parent(s): cebb51f

Delete nyt-ingredients.py

Browse files
Files changed (1) hide show
  1. nyt-ingredients.py +0 -109
nyt-ingredients.py DELETED
@@ -1,109 +0,0 @@
1
- """New York Times Ingredient Phrase Tagger Dataset"""
2
-
3
-
4
- import datasets
5
-
6
-
7
- logger = datasets.logging.get_logger(__name__)
8
-
9
-
10
- _CITATION = """\
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
- }
18
- """
19
-
20
-
21
- _DESCRIPTION = """\
22
- New York Times Ingredient Phrase Tagger Dataset
23
- We use a conditional random field model (CRF) to extract tags from labelled training data, which was tagged by human news assistants.
24
- e wrote about our approach on the [New York Times Open blog](http://open.blogs.nytimes.com/2015/04/09/extracting-structured-data-from-recipes-using-conditional-random-fields/).
25
- This repo contains scripts to extract the Quantity, Unit, Name, and Comments from unstructured ingredient phrases.
26
- We use it on Cooking to format incoming recipes. Given the following input:
27
- ```
28
- 1 pound carrots, young ones if possible
29
- Kosher salt, to taste
30
- 2 tablespoons sherry vinegar
31
- 2 tablespoons honey
32
- 2 tablespoons extra-virgin olive oil
33
- 1 medium-size shallot, peeled and finely diced
34
- 1/2 teaspoon fresh thyme leaves, finely chopped
35
- Black pepper, to taste
36
- ```
37
- """
38
-
39
- _URL = "https://github.com/nytimes/ingredient-phrase-tagger"
40
-
41
- import json
42
-
43
- class NYTIngedientsConfig(datasets.BuilderConfig):
44
- """The NYTIngedients Dataset."""
45
-
46
- def __init__(self, **kwargs):
47
- """BuilderConfig for NYTIngedients.
48
- Args:
49
- **kwargs: keyword arguments forwarded to super.
50
- """
51
- super(NYTIngedientsConfig, self).__init__(**kwargs)
52
-
53
-
54
- class NYTIngedients(datasets.GeneratorBasedBuilder):
55
- """The WNUT 17 Emerging Entities Dataset."""
56
-
57
- BUILDER_CONFIGS = [
58
- NYTIngedientsConfig(
59
- name="nyt-ingredients", version=datasets.Version("1.0.0"), description="The NYTIngedients Dataset"
60
- ),
61
- ]
62
-
63
- def _info(self):
64
- return datasets.DatasetInfo(
65
- description=_DESCRIPTION,
66
- features=datasets.Features(
67
- {
68
- "input": datasets.Value("string"),
69
- "display_input": datasets.Value("string"),
70
- "tokens": datasets.Sequence(datasets.Value("string")),
71
- "index": datasets.Sequence(datasets.Value("string")),
72
- "lengthGroup": datasets.Sequence(datasets.Value("string")),
73
- "isCapitalized": datasets.Sequence(datasets.Value("string")),
74
- "insideParenthesis": datasets.Sequence(datasets.Value("string")),
75
- "label": datasets.Sequence(
76
- datasets.features.ClassLabel(
77
- names=[
78
- 'O',
79
- 'B-COMMENT',
80
- 'I-COMMENT',
81
- 'B-NAME',
82
- 'I-NAME',
83
- 'B-RANGE_END',
84
- 'I-RANGE_END',
85
- 'B-QTY',
86
- 'I-QTY',
87
- 'B-UNIT',
88
- 'I-UNIT',
89
- ]
90
- )
91
- ),
92
- }
93
- ),
94
- supervised_keys=None,
95
- homepage="https://github.com/nytimes/ingredient-phrase-tagger",
96
- citation=_CITATION,
97
- )
98
-
99
- def _split_generators(self, dl_manager):
100
- """Returns SplitGenerators."""
101
- return [
102
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": "nyt-ingredients.crf.jsonl"}),
103
- ]
104
-
105
- def _generate_examples(self, filepath):
106
- logger.info("⏳ Generating examples from = %s", filepath)
107
- with open(filepath, encoding="utf-8") as fp:
108
- for i, line in enumerate(fp):
109
- yield i, json.loads(line)