-
Notifications
You must be signed in to change notification settings - Fork 3
/
preprocessing.py
51 lines (44 loc) · 1.18 KB
/
preprocessing.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
import re
def read_user_from_file():
f = open("tw_db/t0.txt", "r")
data = []
for line in f:
data.append(line)
return data
"""
Function to remove the usernames of the user which are not required for further processing
"""
def remove_username(username, data):
data_at = []
for item in data:
if username in item:
item = item.replace(username, "")
data_at.append(item)
return data_at
"""
Function to remove the emoji patterns which are not required for further processing
"""
def remove_emoji(emoji_pattern, data):
data_at = []
for item in data:
item = emoji_pattern.sub(r'', item)
data_at.append(item)
return data_at
"""
Function to remove the symbols which are not required for further processing
"""
def remove(symbol, data):
data_at = []
for item in data:
if symbol in item:
item = item.replace(symbol, "")
data_at.append(item)
return data_at
"""
Function to remove the links which are not required for further processing
"""
def remove_links(data):
data1 = []
for line in data:
data1.append(re.sub(r"\bhttps:\/\/t\.co\/\w*\b", "", line))
return data1