fix regex not doing on the right string

This commit is contained in:
Mylloon 2021-08-05 14:41:05 +02:00
parent 850624329a
commit b326fc151d

View file

@ -47,7 +47,7 @@ class Listener(StreamListener):
tweet = status.text.lower() tweet = status.text.lower()
# recovery of the last "usable" word of the tweet # recovery of the last "usable" word of the tweet
tweetText = sub(r"https?:\/\/\S+| *\?+| *!+| *,+|-|~|\.+|…|\^+|@\S+" + f"|{emojis()}", " ", tweet) # deletion with space tweetText = sub(r"https?:\/\/\S+| *\?+| *!+| *,+|-|~|\.+|…|\^+|@\S+" + f"|{emojis()}", " ", tweet) # deletion with space
tweetText = sub(r"(?<=ui)i+|(?<=na)a+(?<!n)|(?<=quoi)i+|(?<=no)o+(?<!n)|(?<=hei)i+(?<!n)|(?<=si)i+", "", tweet) # deletion without space tweetText = sub(r"(?<=ui)i+|(?<=na)a+(?<!n)|(?<=quoi)i+|(?<=no)o+(?<!n)|(?<=hei)i+(?<!n)|(?<=si)i+", "", tweetText) # deletion without space
lastWord = tweetText.split()[-1:][0] lastWord = tweetText.split()[-1:][0]
if keys["VERBOSE"]: if keys["VERBOSE"]:
print(f"Tweet trouvé de {status._json['user']['screen_name']} (dernier mot : \"{lastWord}\")...", end = " ") print(f"Tweet trouvé de {status._json['user']['screen_name']} (dernier mot : \"{lastWord}\")...", end = " ")