-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitterFilter.py
63 lines (47 loc) · 1.45 KB
/
twitterFilter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import tweepy
import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import nltk
import pickle
def loadPickledData(filePath, default=["default"]):
"""
load an existing pickle file or make a pickle with default data
then return the pickled data
Parameters:
- filePath: the absolute path or the relative path
- default: default value if the path is invalid for some reason
"""
try:
with open(filePath, "rb") as f:
content = pickle.load(f)
except Exception:
content = default
with open(filePath, "wb") as f:
pickle.dump(content, f)
return content
def saveObjUsingPickle(filePath, content):
"""
save the content as a byte file using pickle to a specific location
use the alternate dill function for complex objects
Parameters:
- filePath: The absolute or relative path of the pickle file
- Ex for win: C:\\Users\\....\\filename.pkl
- Ex for linux and mac: /home/username/.../filename.pkl
- content: object to be saved"""
with open(filePath, "wb") as f:
pickle.dump(content, f)
def get_updated_model():
pass
def text_pipeline():
pass
def filter_bad_words(bad_words):
pass
def load_bad_words():
#### get credentials and keys
def main():
bad_text = "hello I hate you, blah, blah blah, epson lorem wefewufweiufewfui"
#info = get_updated_model()
if if __name__ == "__main__":
main()