# 1 string_functions = { "ascii_lowercase" : ( 0, fm.fcall0(ascii_lowercase)), "ascii_uppercase" : ( 0, fm.fcall0(ascii_uppercase)), "digits" : ( 0, fm.fcall0(digits)), "hexdigits" : ( 0, fm.fcall0(hexdigits)), "letters" : ( 0, fm.fcall0(letters)), "lowercase" : ( 0, fm.fcall0(lowercase)), "octdigits" : ( 0, fm.fcall0(octdigits)), "punctuation" : ( 0, fm.fcall0(punctuation)), "printable" : ( 0, fm.fcall0(printable)), "uppercase" : ( 0, fm.fcall0(uppercase)), "whitespace" : ( 0, fm.fcall0(whitespace)), "capitalize" : ( 1, fm.mcall1("capitalize")), "find" : ( 2, fm.mcall2("find")), # INCOMPLETE, more poss "rfind" : ( 2, fm.mcall2("rfind")), # INCOMPLETE, more poss "index" : ( 2, fm.mcall2("index")), # INCOMPLETE, more poss "rindex" : ( 2, fm.mcall2("rindex")), # INCOMPLETE, more poss "count" : ( 2, fm.mcall2("count")), # INCOMPLETE, more poss "lower" : ( 1, fm.mcall1("lower")), "split" : ( 2, fm.mcall2("split")), # INCOMPLETE, more poss "rsplit" : ( 2, fm.mcall2("rsplit")), # INCOMPLETE, more poss "join" : ( 2, fm.mcall2("join")), # INCOMPLETE, more poss "lstrip" : ( 2, fm.mcall2("lstrip")), # INCOMPLETE, more poss "rstrip" : ( 2, fm.mcall2("rstrip")), # INCOMPLETE, more poss "strip" : ( 2, fm.mcall2("strip")), # INCOMPLETE, more poss "swapcase" : ( 1, fm.mcall1("swapcase")), "translate" : ( 3, fm.mcall3("translate")), "upper" : ( 1, fm.mcall1("upper")), "ljust" : ( 3, fm.mcall3("ljust")),
# 1 string_functions = { "ascii_lowercase": (0, fm.fcall0(ascii_lowercase)), "ascii_uppercase": (0, fm.fcall0(ascii_uppercase)), "digits": (0, fm.fcall0(digits)), "hexdigits": (0, fm.fcall0(hexdigits)), "letters": (0, fm.fcall0(letters)), "lowercase": (0, fm.fcall0(lowercase)), "octdigits": (0, fm.fcall0(octdigits)), "punctuation": (0, fm.fcall0(punctuation)), "printable": (0, fm.fcall0(printable)), "uppercase": (0, fm.fcall0(uppercase)), "whitespace": (0, fm.fcall0(whitespace)), "capitalize": (1, fm.mcall1("capitalize")), "find": (2, fm.mcall2("find")), # INCOMPLETE, more poss "rfind": (2, fm.mcall2("rfind")), # INCOMPLETE, more poss "index": (2, fm.mcall2("index")), # INCOMPLETE, more poss "rindex": (2, fm.mcall2("rindex")), # INCOMPLETE, more poss "count": (2, fm.mcall2("count")), # INCOMPLETE, more poss "lower": (1, fm.mcall1("lower")), "split": (2, fm.mcall2("split")), # INCOMPLETE, more poss "rsplit": (2, fm.mcall2("rsplit")), # INCOMPLETE, more poss "join": (2, fm.mcall2("join")), # INCOMPLETE, more poss "lstrip": (2, fm.mcall2("lstrip")), # INCOMPLETE, more poss "rstrip": (2, fm.mcall2("rstrip")), # INCOMPLETE, more poss "strip": (2, fm.mcall2("strip")), # INCOMPLETE, more poss "swapcase": (1, fm.mcall1("swapcase")), "translate": (3, fm.mcall3("translate")), "upper": (1, fm.mcall1("upper")), "ljust": (3, fm.mcall3("ljust")),
tdict = {} tdict['text'] = item[0] tdict['weight'] = int(item[1] * self.max_words) res.append(tdict) return res def createWordcloud(max_words): return Wordcloud(int(max_words)) wordcloud_functions = { "createWordcloud": (1, fm.fcall1(createWordcloud)), "getwords": (1, fm.fcall1(getwords)), "stopwords": (0, fm.fcall0(stopwords)), "addText": (2, fm.mcall2(Wordcloud.addText)), "update_wordcloud": (2, fm.fcall2(update_wordcloud)), "getWordWeights": (1, fm.mcall1(Wordcloud.getWordWeights)), } ECA_parser.functions.update(wordcloud_functions) # Test function. if __name__ == '__main__': print("#!TWORDCLOUD") wc = createWordcloud(15) wc.addText( '@vessie @Tapz @Scarbir Ik ben in Enschede zaterdag! Batavierenrace. Veel plezier!' ) wc.addText( 'Ik heb dit weekend bijna 10km hardgelopen, dus vind eigenlijk wel dat ik volgend weekend naar het feestje vd #batavierenrace mag.'
res = [] for item in final: tdict = {} tdict['text'] = item[0] tdict['weight'] = int(item[1]*self.max_words) res.append(tdict) return res def createWordcloud(max_words): return Wordcloud(int(max_words)) wordcloud_functions = { "createWordcloud" : ( 1, fm.fcall1(createWordcloud)), "getwords" : ( 1, fm.fcall1(getwords)), "stopwords" : ( 0, fm.fcall0(stopwords)), "addText" : ( 2, fm.mcall2(Wordcloud.addText)), "update_wordcloud" : ( 2, fm.fcall2(update_wordcloud)), "getWordWeights" : ( 1, fm.mcall1(Wordcloud.getWordWeights)), } ECA_parser.functions.update( wordcloud_functions ) # Test function. if __name__ == '__main__': print("#!TWORDCLOUD") wc = createWordcloud(15) wc.addText('@vessie @Tapz @Scarbir Ik ben in Enschede zaterdag! Batavierenrace. Veel plezier!') wc.addText('Ik heb dit weekend bijna 10km hardgelopen, dus vind eigenlijk wel dat ik volgend weekend naar het feestje vd #batavierenrace mag.') wc.addText('Bataradio doet live verslag Batavierenrace http://t.co/6FVfQE') wc.getWordWeights()