EmojiCluster.py
def map_emoji(self, emoji, topn=20, boundary=0.72, print_most_sim=False,
                  raise_error=False, force=False):
        """
        topn (int): the number of object it look at when using e2v. It will
        search through the topn most similar and see if any is below the
        boundary. If so if the similar output is valid in the fit it will
        return the given value.
        boundary (float): the similarity boundary, when using e2v.
        print_most_sim (bool): Print most similar.
        force (bool): if true ignore whether the model isfit
        """
        if (self.isfit is False) and (force is False):
            raise Exception("Emojicluster is not yet fit. Please fit before" +
                            "calling this function")
        if emoji in self.mapping:
            emoji = self.mapping[emoji]

        if emoji in self.emoji_count:
            return emoji
        elif self.__use_e2v and (emoji in self.e2v):
            sim = self.e2v.most_similar(emoji, topn=topn)

            if print_most_sim:
                [print(e, "\t", score) for e, score in sim]

            for e, score in sim:
                if ((e in self.emoji_count) or
                        (e in self.mapping and
                         (self.mapping[e] in self.emoji_count))):
                    if boundary and (score < boundary):
                        if raise_error:
                            raise Exception(f"Could not replace the emoji ({emoji}) with {e} \
                                as the similarity ({score}) < boundary")
                        return None
                    if e in self.mapping:
                        self.mapping[emoji] = self.mapping[e]
                        return self.mapping[e]
                    else:
                        self.mapping[emoji] = e
        if raise_error:
            raise Exception("Emoji not in mapping and either e2v is set to" +
                            "false or the emoji is not defined in the top" +
                            f"{topn} of most similar e2v")
        return None

        topn (int): the number of object it look at when using e2v. It will
        search through the topn most similar and see if any is below the
        boundary. If so if the similar output is valid in the fit it will
        return the given value.
        boundary (float): the similarity boundary, when using e2v.
        print_most_sim (bool): Print most similar.
        force (bool): if true ignore whether the model isfit
        
topn (int): the number of object it look at when using e2v. It will
search through the topn most similar and see if any is below the
boundary. If so if the similar output is valid in the fit it will
return the given value.
boundary (float): the similarity boundary, when using e2v.
print_most_sim (bool): Print most similar.
force (bool): if true ignore whether the model isfit
topn ( int ) : the number of object it look at when using e2v . It will search through the topn most similar and see if any is below the boundary . If so if the similar output is valid in the fit it will return the given value . boundary ( float ) : the similarity boundary when using e2v . print_most_sim ( bool ) : Print most similar . force ( bool ) : if true ignore whether the model isfit
def map_emoji(self, emoji, topn=20, boundary=0.72, print_most_sim=False,
                  raise_error=False, force=False):
        if (self.isfit is False) and (force is False):
            raise Exception("Emojicluster is not yet fit. Please fit before" +
                            "calling this function")
        if emoji in self.mapping:
            emoji = self.mapping[emoji]
        if emoji in self.emoji_count:
            return emoji
        elif self.__use_e2v and (emoji in self.e2v):
            sim = self.e2v.most_similar(emoji, topn=topn)
            if print_most_sim:
                [print(e, "\t", score) for e, score in sim]
            for e, score in sim:
                if ((e in self.emoji_count) or
                        (e in self.mapping and
                         (self.mapping[e] in self.emoji_count))):
                    if boundary and (score < boundary):
                        if raise_error:
                            raise Exception(f"Could not replace the emoji ({emoji}) with {e} \
                                as the similarity ({score}) < boundary")
                        return None
                    if e in self.mapping:
                        self.mapping[emoji] = self.mapping[e]
                        return self.mapping[e]
                    else:
                        self.mapping[emoji] = e
        if raise_error:
            raise Exception("Emoji not in mapping and either e2v is set to" +
                            "false or the emoji is not defined in the top" +
                            f"{topn} of most similar e2v")
        return None
def map_emoji ( self , emoji , topn = 20 , boundary = 0.72 , print_most_sim = False , raise_error = False , force = False ) : if ( self . isfit is False ) and ( force is False ) : raise Exception ( "Emojicluster is not yet fit. Please fit before" + "calling this function" ) if emoji in self . mapping : emoji = self . mapping [ emoji ] if emoji in self . emoji_count : return emoji elif self . __use_e2v and ( emoji in self . e2v ) : sim = self . e2v . most_similar ( emoji , topn = topn ) if print_most_sim : [ print ( e , "\t" , score ) for e , score in sim ] for e , score in sim : if ( ( e in self . emoji_count ) or ( e in self . mapping and ( self . mapping [ e ] in self . emoji_count ) ) ) : if boundary and ( score < boundary ) : if raise_error : raise Exception ( f"Could not replace the emoji ({emoji}) with {e} \
                                as the similarity ({score}) < boundary" ) return None if e in self . mapping : self . mapping [ emoji ] = self . mapping [ e ] return self . mapping [ e ] else : self . mapping [ emoji ] = e if raise_error : raise Exception ( "Emoji not in mapping and either e2v is set to" + "false or the emoji is not defined in the top" + f"{topn} of most similar e2v" ) return None
topn (int): the number of object it look at when using e2v.
topn ( int ) : the number of object it look at when using e2v .
"""
        topn (int): the number of object it look at when using e2v. It will
        search through the topn most similar and see if any is below the
        boundary. If so if the similar output is valid in the fit it will
        return the given value.
        boundary (float): the similarity boundary, when using e2v.
        print_most_sim (bool): Print most similar.
        force (bool): if true ignore whether the model isfit
        """
self
emoji
topn
boundary
print_most_sim
raise_error
force