augustoperes commited on
Commit
e0a3f14
·
1 Parent(s): e1c524a
Files changed (1) hide show
  1. mtg_text.py +6 -3
mtg_text.py CHANGED
@@ -1,6 +1,8 @@
1
  """Loading script"""
2
  import datasets
3
 
 
 
4
  _DESCRIPTION = "Magic the Gathering card text dataset"
5
  """We have two .json files with the train and validation cards. The
6
  json is basically a list of dictionaries with the following keys:
@@ -68,9 +70,10 @@ class MTGCardText(datasets.GeneratorBasedBuilder):
68
  Yields:
69
  dictionaries containing "card_name", "type_line" and "oracle_text"
70
  """
71
- with open(filepath, encoding="utf-8") as f:
72
- for id_, row in enumerate(f):
73
- row = row.strip()
 
74
  yield id_, {
75
  "card_name": row["card_name"],
76
  "type_line": row["type_line"],
 
1
  """Loading script"""
2
  import datasets
3
 
4
+ import json
5
+
6
  _DESCRIPTION = "Magic the Gathering card text dataset"
7
  """We have two .json files with the train and validation cards. The
8
  json is basically a list of dictionaries with the following keys:
 
70
  Yields:
71
  dictionaries containing "card_name", "type_line" and "oracle_text"
72
  """
73
+ # open the json file with all the cards
74
+ with open(file, encoding="utf-8") as f:
75
+ data = json.load(f)
76
+ for id_, row in enumerate(data):
77
  yield id_, {
78
  "card_name": row["card_name"],
79
  "type_line": row["type_line"],