def get_wiktionary_def_image(self,word,dictionary,file_type='png',width=0,height=0,color="Black",fontsize=10): tmp = dictionary.split("-") src_lang = tmp[0] dest_lang = tmp[1] meaning = get_def(word,src_lang,dest_lang) if meaning == None: return no_meaning_found else: return renderer.render_text(meaning,file_type,0,0,color,font_size=fontsize)
def messageHandler(self, conn, message_node): word = message_node.getBody() output = "" if word: if word == "hi" or word == "Hi" or word == "Hello" or word == "hello": output = "നമസ്കാരം! \n" output += "ഞാന് സ്വതന്ത്ര മലയാളം കമ്പ്യൂട്ടിങ്ങിന്റെ ഇംഗ്ലീഷ് മലയാളം നിഘണ്ടു." + "\n" output += "ഇംഗ്ലീഷ് വാക്കുകളുടെ അര്ത്ഥം കണ്ടുപിടിക്കാന് എനിക്കു നിങ്ങളെ സഹായിക്കാന് കഴിയും." + "\n" output += "അര്ത്ഥമറിയേണ്ട വാക്കു് ചോദിച്ചോളൂ." + "\n" output += "ശുഭദിനാശംസകള് നേരുന്നു!" else: dictoutput = self.getdef(word) if dictoutput: output += "From SMC English-Malayalam Dictionary:\n" output += dictoutput conn.send(xmpp.Message(message_node.getFrom(), output)) output = "" wikioutput = wiktionary.get_def(word, "ml", "ml") if wikioutput: output += "From Malayalam wiktionary:\n" output += wikioutput.encode("utf-8") if dictoutput == None and wikioutput == None: output = "ക്ഷമിക്കണം. ഈ വാക്കിന്റെ അര്ത്ഥം കണ്ടെത്താനായില്ല." hun = hunspell.HunSpell( '/usr/share/myspell/dicts/en_US.dic', '/usr/share/myspell/dicts/en_US.aff') output += "\nDid you mean: \n" if hun.spell(word) is False: wordlist = hun.suggest(word) #print wordlist for suggword in wordlist: #print suggword hdictoutput = self.getdef(suggword) hwikioutput = wiktionary.get_def( suggword, "ml", "ml") if hdictoutput is not None or hwikioutput is not None: output += "\t" + suggword + "\n" conn.send(xmpp.Message(message_node.getFrom(), output)) raise NodeProcessed # This stanza is fully processed
def messageHandler(self, conn,message_node): word = message_node.getBody() output= "" if word : if word.lower() == "hi" or word.lower() == "hello" : output = "നമസ്കാരം! \n" output += "ഞാന് സ്വതന്ത്ര മലയാളം കമ്പ്യൂട്ടിങ്ങിന്റെ ഇംഗ്ലീഷ് മലയാളം നിഘണ്ടു."+"\n" output += "ഇംഗ്ലീഷ് വാക്കുകളുടെ അര്ത്ഥം കണ്ടുപിടിക്കാന് എനിക്കു നിങ്ങളെ സഹായിക്കാന് കഴിയും."+"\n" output += "അര്ത്ഥമറിയേണ്ട വാക്കു് ചോദിച്ചോളൂ."+"\n" output += "ശുഭദിനാശംസകള് നേരുന്നു!" else: dictoutput = self.getdef(word) if dictoutput: output += "From SMC English-Malayalam Dictionary:\n" output += dictoutput conn.send( xmpp.Message( message_node.getFrom() ,output)) output = "" wikioutput = wiktionary.get_def(word, "ml","ml") if wikioutput: output += "From Malayalam wiktionary:\n" output += wikioutput.encode("utf-8") if dictoutput== None and wikioutput==None: output = "ക്ഷമിക്കണം. ഈ വാക്കിന്റെ അര്ത്ഥം കണ്ടെത്താനായില്ല." hun = hunspell.HunSpell('/usr/share/myspell/dicts/en_US.dic', '/usr/share/myspell/dicts/en_US.aff') output += "\nDid you mean: \n" if hun.spell(word) is False: wordlist = hun.suggest(word) #print wordlist for suggword in wordlist: #print suggword hdictoutput = self.getdef(suggword) hwikioutput = wiktionary.get_def(suggword, "ml","ml") if hdictoutput is not None or hwikioutput is not None: output+= "\t" + suggword + "\n" conn.send( xmpp.Message( message_node.getFrom() ,output)) raise NodeProcessed # This stanza is fully processed
def get_wiktionary_def_image(self, word, dictionary, file_type='png', width=0, height=0, color="Black", fontsize=10): """ Returns an image of the definition. Useful for machine independant results """ tmp = dictionary.split("-") src_lang = tmp[0] dest_lang = tmp[1] meaning = get_def(word, src_lang, dest_lang) if meaning is None: return no_meaning_found else: return renderer.render_text(meaning, file_type=file_type, width=width, height=height, color=color, font_size=fontsize)
def get_wiktionary_def_image(self, word, dictionary, file_type='png', width=0, height=0, color="Black", fontsize=10): tmp = dictionary.split("-") src_lang = tmp[0] dest_lang = tmp[1] meaning = get_def(word, src_lang, dest_lang) if meaning == None: return no_meaning_found else: return renderer.render_text(meaning, file_type, 0, 0, color, font_size=fontsize)