super_views.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Chat-Bot 作者: FredLoh 项目源码 文件源码
def even_or_odd(self, message=None, match=None, to=None):
        is_odd = len(match.group("evenOrOdd")) % 2
        num = random.randint(1, 10)
        if (is_odd and num % 2) or (not is_odd and not num % 2):
            return TextMessageProtocolEntity("[%d]\nYou win." % num, to=message.getFrom())
        else:
            return TextMessageProtocolEntity("[%d]\nYou lose!" % num, to=message.getFrom())

    # def beban_spell_checker(self, message=None, match=None, to=None):
    #     print(message.getBody())
    #     correctionList = ""
    #     text = message.getBody()
    #     d = enchant.DictWithPWL("es_MX","wordList.txt")
    #     d_en = enchant.Dict("en_US")

    #     wordList = text.split()
    #     for word in wordList:
    #       if(word.isalnum() == True):
    #         print(word)
    #         if(d.check(word) == False):
    #             # if(d_en.check(word) == False):
    #           solutions = d.suggest(word)
    #           print(solutions)
    #           sol = str(solutions[0])
    #           if(sol.isalnum() == False):
    #             correctionList += sol + "* "
    #     if (correctionList != ""):
    #         print(correctionList)
    #         return TextMessageProtocolEntity(correctionList, to=message.getFrom())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号