From 46bf93206b7fe9b50852dd0222acaf90509b97ee Mon Sep 17 00:00:00 2001
From: Felix <felixwelter@gmail.com>
Date: Mon, 27 Apr 2020 15:47:57 +0200
Subject: [PATCH] Add helpers for lexicon reading

---
 social_sent_helpers.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 social_sent_helpers.py

diff --git a/social_sent_helpers.py b/social_sent_helpers.py
new file mode 100644
index 0000000..d690bf0
--- /dev/null
+++ b/social_sent_helpers.py
@@ -0,0 +1,16 @@
+import pandas as pd
+from os import listdir
+from os.path import isfile, join
+from tqdm.notebook import tqdm
+
+def read_lexicon(name):
+    return pd.read_csv("lexicons\\"+ name +".tsv", names=["word", "so", "sd"], header=None, sep="\t", engine="python")
+
+def list_lexicons():
+    return pd.Series([f[:-4] for f in listdir("lexicons") if isfile(join("lexicons", f))]).sort_values()
+
+def read_all_lexicons():
+    return [read_lexicon(name) for name in tqdm(list_lexicons(), desc="Reading lexicons from disk")]
+
+games_list = ["gaming", "Smite", "skyrim", "PS4", "xboxone", "Eve"]
+sports_list = ["sports", "hockey", "Fitness", "baseball", "MMA", "bicycling"]
\ No newline at end of file
-- 
GitLab