laugustyniak commited on
Commit
1341e14
1 Parent(s): 3862aa2

update loading script

Browse files
Files changed (1) hide show
  1. political_advertising_loader.py +9 -3
political_advertising_loader.py CHANGED
@@ -102,11 +102,17 @@ class PoliticalAdvertisingDataset(datasets.GeneratorBasedBuilder):
102
 
103
  def _generate_examples(self, filepath: str):
104
  logger.info("⏳ Generating examples from = %s", filepath)
105
- df = pd.read_json(filepath)
 
 
 
 
 
 
106
 
107
  for row_id, row in df.iterrows():
108
  yield row_id, {
109
  "id": str(row_id),
110
- "tokens": [str(token) for token in row.tokens],
111
- "tags": [str(tag) for tag in row.tags],
112
  }
 
102
 
103
  def _generate_examples(self, filepath: str):
104
  logger.info("⏳ Generating examples from = %s", filepath)
105
+ print("⏳ Generating examples from = %s", filepath)
106
+ df = pd.read_json(
107
+ filepath,
108
+ orient="records",
109
+ dtype={"tokens": list, "tags": list, "url": str, "tweet_id": str},
110
+ )
111
+ print(f"Shape: {df.shape}")
112
 
113
  for row_id, row in df.iterrows():
114
  yield row_id, {
115
  "id": str(row_id),
116
+ "tokens": row.tokens,
117
+ "tags": row.tags,
118
  }