gsarti commited on
Commit
3c4d251
1 Parent(s): ec3da17

Moved to CSV

Browse files
Files changed (3) hide show
  1. ik_nlp_22_slp.py +6 -15
  2. slp3ed.csv +0 -0
  3. slp3ed.tsv +0 -0
ik_nlp_22_slp.py CHANGED
@@ -2,6 +2,7 @@ import csv
2
  import sys
3
 
4
  import datasets
 
5
  from typing import List
6
 
7
  csv.field_size_limit(sys.maxsize)
@@ -27,7 +28,7 @@ _HOMEPAGE = "https://www.rug.nl/masters/information-science/?lang=en"
27
 
28
  _LICENSE = "See https://web.stanford.edu/~jurafsky/slp3/"
29
 
30
- _PARAGRAPHS_URL = "https://huggingface.co/datasets/GroNLP/ik-nlp-22_slp/raw/main/slp3ed.tsv"
31
 
32
 
33
  class IkNlp22SlpConfig(datasets.BuilderConfig):
@@ -55,12 +56,6 @@ class IkNlp22Slp(datasets.GeneratorBasedBuilder):
55
  IkNlp22SlpConfig(
56
  name="paragraphs",
57
  features=["n_chapter", "chapter", "n_section", "section", "n_subsection", "subsection", "text"],
58
- <<<<<<< HEAD
59
- ||||||| 5e078e2
60
- data_url="https://huggingface.co/datasets/GroNLP/ik-nlp-22_slp/resolve/main/slp3ed.tsv"
61
- =======
62
- data_url="https://huggingface.co/datasets/GroNLP/ik-nlp-22_slp/raw/main/slp3ed.tsv"
63
- >>>>>>> fc2063e6e3a23866446fac01533b3010c38b3a46
64
  ),
65
  ]
66
 
@@ -91,11 +86,7 @@ class IkNlp22Slp(datasets.GeneratorBasedBuilder):
91
 
92
  def _generate_examples(self, filepath: str, split: str, features: List[str]):
93
  """Yields examples as (key, example) tuples."""
94
- with open(filepath, encoding="utf8") as f:
95
- for id_, row in enumerate(f):
96
- if id_ == 0:
97
- continue
98
- fields = row.strip().split("\t")
99
- yield id_, {
100
- k:v.strip() for k,v in zip(features, fields)
101
- }
 
2
  import sys
3
 
4
  import datasets
5
+ import pandas as pd
6
  from typing import List
7
 
8
  csv.field_size_limit(sys.maxsize)
 
28
 
29
  _LICENSE = "See https://web.stanford.edu/~jurafsky/slp3/"
30
 
31
+ _PARAGRAPHS_URL = "https://huggingface.co/datasets/GroNLP/ik-nlp-22_slp/raw/main/slp3ed.csv"
32
 
33
 
34
  class IkNlp22SlpConfig(datasets.BuilderConfig):
 
56
  IkNlp22SlpConfig(
57
  name="paragraphs",
58
  features=["n_chapter", "chapter", "n_section", "section", "n_subsection", "subsection", "text"],
 
 
 
 
 
 
59
  ),
60
  ]
61
 
 
86
 
87
  def _generate_examples(self, filepath: str, split: str, features: List[str]):
88
  """Yields examples as (key, example) tuples."""
89
+ data = pd.read_csv(filepath)
90
+ for id_, row in data.iterrows():
91
+ fields = row.strip().split(",")
92
+ yield id_, row.to_dict()
 
 
 
 
slp3ed.csv ADDED
The diff for this file is too large to render. See raw diff
 
slp3ed.tsv DELETED
The diff for this file is too large to render. See raw diff