<commit_before>from datetime import datetime
import typing

from twitter_feed.core.user import User
from twitter_feed.core.hashtag import Hashtag


class Tweet:

    def __init__(
        self,
        id_: str = None,
        text: str = None,
        date: str = None,
        hashtags: typing.List[str] = None,
        mentions: typing.List[str] = None,
        user: User = None
    ):
        self.id_ = id_
        self.text = text
        self.date = date
        self.hashtags = hashtags
        self.mentions = mentions
        self.user = user

    def __eq__(self, other):
        if isinstance(other, self.__class__):
            return self.__dict__ == other.__dict__
        return NotImplemented

    def __ne__(self, other):
        if isinstance(other, self.__class__):
            return not self.__eq__(other)
        return NotImplemented

    @classmethod
    def from_dict(cls, tweet_dict: dict = None):
        return cls(
            id_=tweet_dict.get('id_str'),
            text=tweet_dict.get('text'),
            date=datetime.strptime(tweet_dict.get('created_at'), '%a %b %d %X %z %Y'),
            hashtags=[Hashtag.from_dict(hsh) for hsh in tweet_dict.get('hashtags')],
            mentions=[User.from_dict(usr) for usr in tweet_dict.get('mentions')],
            user=User.from_dict(tweet_dict['user'])
        )

    @staticmethod
    def tweets_from_list(tweets_list: typing.List[dict]):
        for tweet_dict in tweets_list:
            pass<commit_msg>fixed tweet.from_dict<commit_after>from datetime import datetime
import typing

from twitter_feed.core.user import User
from twitter_feed.core.hashtag import Hashtag


class Tweet:

    def __init__(
        self,
        id_: str = None,
        text: str = None,
        date: str = None,
        hashtags: typing.List[str] = None,
        mentions: typing.List[str] = None,
        user: User = None
    ):
        self.id_ = id_
        self.text = text
        self.date = date
        self.hashtags = hashtags
        self.mentions = mentions
        self.user = user

    def __eq__(self, other):
        if isinstance(other, self.__class__):
            return self.__dict__ == other.__dict__
        return NotImplemented

    def __ne__(self, other):
        if isinstance(other, self.__class__):
            return not self.__eq__(other)
        return NotImplemented

    @classmethod
    def from_dict(cls, tweet_dict: dict = None):
        return cls(
            id_=tweet_dict.get('id_str'),
            text=tweet_dict.get('text'),
            date=datetime.strptime(tweet_dict.get('created_at'), '%a %b %d %X %z %Y'),
            hashtags=[Hashtag.from_dict(hsh) for hsh in tweet_dict.get('entities').get('hashtags')],
            mentions=[User.from_dict(usr) for usr in tweet_dict.get('entities').get('user_mentions')],
            user=User.from_dict(tweet_dict['user'])
        )

    @classmethod
    def tweets_from_list(cls, tweets_list: typing.List[dict]):
        tweets = []
        for tweet_dict in tweets_list:
            tweets.append(
                cls.from_dict(tweet_dict)
            )

        return tweets
{'fraction_non_alphanumeric': 0.1055484693877551, 'fraction_numerical': 0.0, 'mean_word_length': 2.214139344262295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '938713', 'n_tokens_mistral': 999, 'n_tokens_neox': 963, 'n_words': 221}