twitter.twint: fix missing mentions in tweet text

This commit is contained in:
Dima Gerasimov 2022-05-30 21:24:23 +01:00
parent 9b72e09957
commit 89090ecea5

View file

@ -66,7 +66,17 @@ class Tweet(NamedTuple):
@property
def text(self) -> str:
return self.row['tweet']
text = self.row['tweet']
mentions_s = self.row['mentions']
if len(mentions_s) > 0:
# at some point for no apparent reasions mentions stopped appearing from tweet text in twint
# note that the order is still inconsisnent against twitter archive, but not much we can do
mentions = mentions_s.split(',')
for m in mentions:
# ugh. sometimes they appear as lowercase in text, sometimes not..
if m.lower() not in text.lower():
text = f'@{m} ' + text
return text
@property
def urls(self) -> List[str]: