-
Notifications
You must be signed in to change notification settings - Fork 2
/
replace.py
27 lines (26 loc) · 1007 Bytes
/
replace.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
from textblob import TextBlob
import random
from scrape import getEmojiList
def tagWords(inputString):
string = TextBlob(inputString)
sets = set(['NN', 'NNS', 'PRP', 'VBD', 'JJ'])
newString = ""
for word in string.tags:
if(word[1] in sets and len(word[0]) > 1):
emoji = getEmojiList(word[0])
if(emoji):
num = random.randint(0,10)
emote = list(emoji.values())[random.randint(0,int(len(emoji.values())/2))]
if(num<=5):
newString += word[0] + emote + " "
elif(num<=7):
newString += word[0] + emote + emote + " "
elif(num<=9):
newString += word[0] + emote + emote + emote + " "
else: #num==10
newString += emote + emote + word[0] + emote + emote + " "
else:
newString += word[0] + " "
else:
newString += word[0] + " "
return newString