#!/usr/bin/env python """Fetch the two EmoTweetID files this dataset is derived from (CC BY 4.0, Mendeley Data jzgnjsff9f). data/file1.csv : tweet, label - the 2,243 manually annotated tweets (6 Ekman emotions) data/file2.csv : tweet_en - the same rows, English translation, aligned on `index` Both files are the `file_downloaded` endpoints of the dataset's public file ids; the row order and index are identical, which `label_anger.py` asserts before it joins them. """ import os import sys import urllib.request FILES = { "data/file1.csv": "https://data.mendeley.com/public-files/datasets/jzgnjsff9f/files/" "56002c37-6fad-4949-b821-c803e9d5b31d/file_downloaded", "data/file2.csv": "https://data.mendeley.com/public-files/datasets/jzgnjsff9f/files/" "c6503598-7b82-4d5e-906a-93386d73239a/file_downloaded", } def main(): for path, url in FILES.items(): if os.path.exists(path) and os.path.getsize(path) > 10_000: print("[fetch] %s already present (%d bytes)" % (path, os.path.getsize(path))) continue os.makedirs(os.path.dirname(path), exist_ok=True) print("[fetch] %s <- %s" % (path, url)) with urllib.request.urlopen(url, timeout=120) as r, open(path + ".part", "wb") as fh: fh.write(r.read()) os.replace(path + ".part", path) import pandas as pd f1, f2 = pd.read_csv("data/file1.csv", index_col=0), pd.read_csv("data/file2.csv", index_col=0) print("[fetch] file1 %s %s | file2 %s | aligned: %s | anger rows: %d" % ( f1.shape, f1.columns.tolist(), f2.shape, (f1.index == f2.index).all(), int((f1["label"] == "anger").sum()))) if __name__ == "__main__": sys.exit(main())