From bb4c77612be4aaa6a7a7f818e9b147e14e47a970 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Mon, 30 May 2022 21:24:23 +0100 Subject: [PATCH] twitter.twint: fix missing mentions in tweet text --- my/twitter/twint.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/my/twitter/twint.py b/my/twitter/twint.py index 13b63cc..5ba0460 100644 --- a/my/twitter/twint.py +++ b/my/twitter/twint.py @@ -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]: