arxyzan commited on
Commit
c1ccaf7
1 Parent(s): 631d352

Update sentiment_digikala_snappfood.py

Browse files
Files changed (1) hide show
  1. sentiment_digikala_snappfood.py +2 -21
sentiment_digikala_snappfood.py CHANGED
@@ -14,27 +14,9 @@ _DOWNLOAD_URLS = {
14
  }
15
 
16
 
17
- class SentimentDigikalaSnappfoodConfig(datasets.BuilderConfig):
18
- """BuilderConfig for SentimentMixedV1"""
19
-
20
- def __init__(self, **kwargs):
21
- """BuilderConfig for SentimentMixedV1.
22
- Args:
23
- **kwargs: keyword arguments forwarded to super.
24
- """
25
- super(SentimentDigikalaSnappfoodConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
26
-
27
-
28
  class SentimentDigikalaSnappfood(datasets.GeneratorBasedBuilder):
29
  """Sentiment analysis on Digikala/SnappFood comments"""
30
 
31
- BUILDER_CONFIGS = [
32
- SentimentDigikalaSnappfoodConfig(
33
- name="plain_text",
34
- description="Plain text",
35
- )
36
- ]
37
-
38
  def _info(self):
39
  return datasets.DatasetInfo(
40
  description=_DESCRIPTION,
@@ -56,13 +38,12 @@ class SentimentDigikalaSnappfood(datasets.GeneratorBasedBuilder):
56
 
57
  def _generate_examples(self, filepath):
58
  """Generate examples."""
59
- # For labeled examples, extract the label from the path.
60
  label_mapping = {"negative": 0, "positive": 1, "neutral": 2}
61
  with open(filepath, encoding="utf-8") as csv_file:
62
  csv_reader = csv.reader(
63
- csv_file, quotechar='"', delimiter=",", quoting=csv.QUOTE_ALL, skipinitialspace=True
64
  )
65
  for id_, row in enumerate(csv_reader):
66
  text, label = row
67
  label = label_mapping[label]
68
- yield id_, {"text": text, "label": label}
 
14
  }
15
 
16
 
 
 
 
 
 
 
 
 
 
 
 
17
  class SentimentDigikalaSnappfood(datasets.GeneratorBasedBuilder):
18
  """Sentiment analysis on Digikala/SnappFood comments"""
19
 
 
 
 
 
 
 
 
20
  def _info(self):
21
  return datasets.DatasetInfo(
22
  description=_DESCRIPTION,
 
38
 
39
  def _generate_examples(self, filepath):
40
  """Generate examples."""
 
41
  label_mapping = {"negative": 0, "positive": 1, "neutral": 2}
42
  with open(filepath, encoding="utf-8") as csv_file:
43
  csv_reader = csv.reader(
44
+ csv_file, quotechar='"', skipinitialspace=True
45
  )
46
  for id_, row in enumerate(csv_reader):
47
  text, label = row
48
  label = label_mapping[label]
49
+ yield id_, {"text": text, "label": label}