heegyu commited on
Commit
1c171b3
1 Parent(s): 5295678

script 다시 제대로 만듦!!

Browse files
Files changed (1) hide show
  1. kowikitext.py +16 -7
kowikitext.py CHANGED
@@ -49,7 +49,7 @@ _LICENSE = "Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
49
  # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
50
  # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
51
  _URLS = {
52
- "20221001": "https://huggingface.co/datasets/heegyu/kowikitext/raw/main/kowikitext-20221001.parquet",
53
  }
54
 
55
 
@@ -111,13 +111,22 @@ class KowikitextDataset(datasets.GeneratorBasedBuilder):
111
  urls = _URLS[self.config.name]
112
  data_dir = dl_manager.download_and_extract(urls)
113
 
 
114
  # no split
115
- return []
 
 
 
 
 
 
 
 
 
116
 
117
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
118
  def _generate_examples(self, filepath, split):
119
- with open(filepath, encoding="utf-8") as f:
120
- for key, row in enumerate(f):
121
- data = json.loads(row)
122
- # Yields examples as (key, example) tuples
123
- yield key, data
 
49
  # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
50
  # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
51
  _URLS = {
52
+ "20221001": "https://huggingface.co/datasets/heegyu/kowikitext/resolve/main/kowikitext-20221001.parquet",
53
  }
54
 
55
 
 
111
  urls = _URLS[self.config.name]
112
  data_dir = dl_manager.download_and_extract(urls)
113
 
114
+
115
  # no split
116
+ return [
117
+ datasets.SplitGenerator(
118
+ name=datasets.Split.TRAIN,
119
+ # These kwargs will be passed to _generate_examples
120
+ gen_kwargs={
121
+ "filepath": data_dir,
122
+ "split": "train",
123
+ },
124
+ ),
125
+ ]
126
 
127
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
128
  def _generate_examples(self, filepath, split):
129
+ import pandas as pd
130
+ df = pd.read_parquet(filepath)
131
+ for key, row in df.iterrows():
132
+ yield int(key), row.to_dict()