EmojiCluster.py
def fit(self, topn, corpus=None, binary=True, counter=None, verbose=True,
            fit_using_e2v=None, boundary=0.72, topn_e2v=20):
        """
        corpus (iter): an iterable object containing strings
        topn (int): The maximum number of token to keep
        binary (bool): should you only count each emoji once pr. text in
        corpus?
        counter (Counter): A counter containing the count of each emoji in the
        corpus, if passed corpus will be ignored. If None will it be estimated
        on the corpus
        boundary (float): not used if fit_using_e2v is False. The desired
        boundary of e2v. See map_emoji
        topn (int): not used if fit_using_e2v is False. See map_emoji

        """
        if (corpus is None) and (counter is None):
            raise ValueError(
                "corpus need to be specified if no counter is given")
        elif counter is None:
            emoji_count = create_emoji_count(
                corpus, binary=binary)
        else:
            emoji_count = counter

        if fit_using_e2v is None:
            fit_using_e2v = True if self.__use_e2v else False

        # collapse using mapping
        emoji_count_ = {}
        for e, n in emoji_count.items():
            if e in self.mapping:
                e = self.mapping[e]
            if e in emoji_count_:
                emoji_count_[e] += n
            else:
                emoji_count_[e] = n
        emoji_count_ = Counter(emoji_count_)

        self.emoji_count = Counter({e: n for e, n in
                                    emoji_count_.most_common(topn)})

        if fit_using_e2v:
            if verbose:
                print(
                    "The followed emojis have been matched using e2v (number in the dataset):")
            for e, n in emoji_count_.items():
                if e in self.mapping:
                    e = self.mapping[e]
                if (e in self.emoji_count) or (e not in self.emoji_desc):
                    continue
                e_ = self.map_emoji(e, boundary=boundary, topn=topn_e2v,
                                    force=True)
                if e_ is not None:
                    if verbose:
                        print(f"{e} = {e_} ({n})")
                    self.emoji_count[e_] += n

        self.__corpus_emoji_count = emoji_count
        self.__corpus_emoji_count_mapped = emoji_count_

        if verbose:
            n_included = sum(self.emoji_count.values())
            p = n_included / sum(emoji_count_.values())
            print(f"The coverage of the emojis is {round(p, 4)} and include:")
            df = counter_to_df(self.emoji_count)
            print_emoji_grid(df["Value"], shape=(20, 10))
            print(
                "Please note that the coverage does not include emoji2vec " +
                "for unseen samples")
        self.isfit = True

        corpus (iter): an iterable object containing strings
        topn (int): The maximum number of token to keep
        binary (bool): should you only count each emoji once pr. text in
        corpus?
        counter (Counter): A counter containing the count of each emoji in the
        corpus, if passed corpus will be ignored. If None will it be estimated
        on the corpus
        boundary (float): not used if fit_using_e2v is False. The desired
        boundary of e2v. See map_emoji
        topn (int): not used if fit_using_e2v is False. See map_emoji

        
corpus (iter): an iterable object containing strings
topn (int): The maximum number of token to keep
binary (bool): should you only count each emoji once pr. text in
corpus.
counter (Counter): A counter containing the count of each emoji in the
corpus, if passed corpus will be ignored. If None will it be estimated
on the corpus
boundary (float): not used if fit_using_e2v is False. The desired
boundary of e2v. See map_emoji
topn (int): not used if fit_using_e2v is False.
corpus ( iter ) : an iterable object containing strings topn ( int ) : The maximum number of token to keep binary ( bool ) : should you only count each emoji once pr . text in corpus . counter ( Counter ) : A counter containing the count of each emoji in the corpus if passed corpus will be ignored . If None will it be estimated on the corpus boundary ( float ) : not used if fit_using_e2v is False . The desired boundary of e2v . See map_emoji topn ( int ) : not used if fit_using_e2v is False .
def fit(self, topn, corpus=None, binary=True, counter=None, verbose=True,
            fit_using_e2v=None, boundary=0.72, topn_e2v=20):
        if (corpus is None) and (counter is None):
            raise ValueError(
                "corpus need to be specified if no counter is given")
        elif counter is None:
            emoji_count = create_emoji_count(
                corpus, binary=binary)
        else:
            emoji_count = counter
        if fit_using_e2v is None:
            fit_using_e2v = True if self.__use_e2v else False
        emoji_count_ = {}
        for e, n in emoji_count.items():
            if e in self.mapping:
                e = self.mapping[e]
            if e in emoji_count_:
                emoji_count_[e] += n
            else:
                emoji_count_[e] = n
        emoji_count_ = Counter(emoji_count_)
        self.emoji_count = Counter({e: n for e, n in
                                    emoji_count_.most_common(topn)})
        if fit_using_e2v:
            if verbose:
                print(
                    "The followed emojis have been matched using e2v (number in the dataset):")
            for e, n in emoji_count_.items():
                if e in self.mapping:
                    e = self.mapping[e]
                if (e in self.emoji_count) or (e not in self.emoji_desc):
                    continue
                e_ = self.map_emoji(e, boundary=boundary, topn=topn_e2v,
                                    force=True)
                if e_ is not None:
                    if verbose:
                        print(f"{e} = {e_} ({n})")
                    self.emoji_count[e_] += n
        self.__corpus_emoji_count = emoji_count
        self.__corpus_emoji_count_mapped = emoji_count_
        if verbose:
            n_included = sum(self.emoji_count.values())
            p = n_included / sum(emoji_count_.values())
            print(f"The coverage of the emojis is {round(p, 4)} and include:")
            df = counter_to_df(self.emoji_count)
            print_emoji_grid(df["Value"], shape=(20, 10))
            print(
                "Please note that the coverage does not include emoji2vec " +
                "for unseen samples")
        self.isfit = True
def fit ( self , topn , corpus = None , binary = True , counter = None , verbose = True , fit_using_e2v = None , boundary = 0.72 , topn_e2v = 20 ) : if ( corpus is None ) and ( counter is None ) : raise ValueError ( "corpus need to be specified if no counter is given" ) elif counter is None : emoji_count = create_emoji_count ( corpus , binary = binary ) else : emoji_count = counter if fit_using_e2v is None : fit_using_e2v = True if self . __use_e2v else False emoji_count_ = { } for e , n in emoji_count . items ( ) : if e in self . mapping : e = self . mapping [ e ] if e in emoji_count_ : emoji_count_ [ e ] += n else : emoji_count_ [ e ] = n emoji_count_ = Counter ( emoji_count_ ) self . emoji_count = Counter ( { e : n for e , n in emoji_count_ . most_common ( topn ) } ) if fit_using_e2v : if verbose : print ( "The followed emojis have been matched using e2v (number in the dataset):" ) for e , n in emoji_count_ . items ( ) : if e in self . mapping : e = self . mapping [ e ] if ( e in self . emoji_count ) or ( e not in self . emoji_desc ) : continue e_ = self . map_emoji ( e , boundary = boundary , topn = topn_e2v , force = True ) if e_ is not None : if verbose : print ( f"{e} = {e_} ({n})" ) self . emoji_count [ e_ ] += n self . __corpus_emoji_count = emoji_count self . __corpus_emoji_count_mapped = emoji_count_ if verbose : n_included = sum ( self . emoji_count . values ( ) ) p = n_included / sum ( emoji_count_ . values ( ) ) print ( f"The coverage of the emojis is {round(p, 4)} and include:" ) df = counter_to_df ( self . emoji_count ) print_emoji_grid ( df [ "Value" ] , shape = ( 20 , 10 ) ) print ( "Please note that the coverage does not include emoji2vec " + "for unseen samples" ) self . isfit = True
corpus (iter): an iterable object containing strings
topn (int): The maximum number of token to keep
binary (bool): should you only count each emoji once pr.
corpus ( iter ) : an iterable object containing strings topn ( int ) : The maximum number of token to keep binary ( bool ) : should you only count each emoji once pr .
"""
        corpus (iter): an iterable object containing strings
        topn (int): The maximum number of token to keep
        binary (bool): should you only count each emoji once pr. text in
        corpus?
        counter (Counter): A counter containing the count of each emoji in the
        corpus, if passed corpus will be ignored. If None will it be estimated
        on the corpus
        boundary (float): not used if fit_using_e2v is False. The desired
        boundary of e2v. See map_emoji
        topn (int): not used if fit_using_e2v is False. See map_emoji

        """ # collapse using mapping
self
topn
corpus
binary
counter
verbose
fit_using_e2v
boundary
topn_e2v