当前位置: 首页>>代码示例>>Python>>正文


Python PyDictionary.antonym方法代码示例

本文整理汇总了Python中PyDictionary.PyDictionary.antonym方法的典型用法代码示例。如果您正苦于以下问题:Python PyDictionary.antonym方法的具体用法?Python PyDictionary.antonym怎么用?Python PyDictionary.antonym使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyDictionary.PyDictionary的用法示例。


在下文中一共展示了PyDictionary.antonym方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dictionary

# 需要导入模块: from PyDictionary import PyDictionary [as 别名]
# 或者: from PyDictionary.PyDictionary import antonym [as 别名]
def dictionary(command):
    dictionary = PyDictionary()
    words = command.split()

    choice = words[0]
    word = str(words[-1])

    print(choice)
    print(word)
    try:
        if choice == "define":
            definition = str(dictionary.meaning(word))
            return(definition)
        elif choice == "synonyms":
            synonyms = dictionary.synonym(word)
            result = ', '.join(synonyms)
            print(result)
            return result
        elif choice == "antonyms":
            antonyms = dictionary.antonym(word)
            result = ', '.join(antonyms)
            print(result)
            return result
        else:
            return "Please retry your question"
    except TypeError:
        return ("Your word had no " + choice)
开发者ID:jcallin,项目名称:eSeMeS,代码行数:29,代码来源:dictionary.py

示例2: antonym

# 需要导入模块: from PyDictionary import PyDictionary [as 别名]
# 或者: from PyDictionary.PyDictionary import antonym [as 别名]
def antonym(word):
	try:
		word = word.lower()
		dictionary = PyDictionary()
		anto_list = (dictionary.antonym(word))
		print("The antonym(s) of the word %s are:"%word)
		for i in range(0,len(anto_list)):
			print (str(i+1)+')'+anto_list[i].encode('ascii'))
	except TypeError:
		word = raw_input("Re-enter the word with the correct spelling: ")
		antonym(word)
开发者ID:nityanandagohain,项目名称:PyDic,代码行数:13,代码来源:main.py

示例3: antonym

# 需要导入模块: from PyDictionary import PyDictionary [as 别名]
# 或者: from PyDictionary.PyDictionary import antonym [as 别名]
    async def antonym(self, word):
        """Checks the dictionary for the antonyms for a given word."""

        word = word.lower()
        result = dictionary.antonym(word)
        try:
            text = self.nym_text_format("antonyms", result, word)
            return await self.bot.say(text)
        except TypeError:
            return await self.bot.say("No results found. Are you " +
                                      "searching for a valid word?")
开发者ID:PookaMustard,项目名称:ushiromiya-beatrice,代码行数:13,代码来源:dictionary.py

示例4: Meaning

# 需要导入模块: from PyDictionary import PyDictionary [as 别名]
# 或者: from PyDictionary.PyDictionary import antonym [as 别名]
class Meaning():
	def __init__(self):
		self.dictionary=PyDictionary()
	def meaning_function(self,query,task="mn"): #task can be meaning, translate,
		fo=open("meaning.txt","w")
		if task == "mn" :
			fo.write("Meaning :")
			fo.write(str(self.dictionary.meaning(query)))
			fo.write("Synonym :")
			fo.write(str(self.dictionary.synonym(query)))
			fo.write("Antonym :")
			fo.write(str(self.dictionary.antonym(query)))
			print (self.dictionary.meaning(query))
		elif task =="tr":
			fo.write("Translation :")
			unicodedata.normalize('NFKD', self.dictionary.translate(query,'hi')).encode('ascii','ignore')
			fo.write(unicodedata.normalize('NFKD', self.dictionary.translate(query,'hi')).encode('ascii','ignore')) ##Unicode to string conversion
			print(self.dictionary.translate(query,'hi'))
		fo.close()
	def __del__(self):
		os.remove("meaning.txt")
开发者ID:SDES-IITB-course-archive,项目名称:SDES_Readout,代码行数:23,代码来源:Meaning.py

示例5: len

# 需要导入模块: from PyDictionary import PyDictionary [as 别名]
# 或者: from PyDictionary.PyDictionary import antonym [as 别名]
            flag = 1
        if (flag == 0 ):
            print "Tweet successful"
        else:
            print "Tweet Failed"

    elif " ".join(message.strip().lower().split()[:2]) == "synonym of":
        bot_response =  dictionary.synonym(" ".join(message.strip().lower().split()[2:]))
        if(len(bot_response) >= 1 ):
            bot_response = ", ".join(bot_response)
        else:
            bot_response = "Sorry i couldn't find the synonym for "," ".join(bot_response)
        print bot_response

    elif " ".join(message.strip().lower().split()[:2]) == "antonym of":        
        bot_response =  (dictionary.antonym(" ".join(message.strip().lower().split()[2:])))
        if(len(bot_response) >= 1 ):
            bot_response = ", ".join(bot_response)
        else:
            bot_response = "Sorry i couldn't find the antonym for "," ".join(bot_response)
        print bot_response


    elif " ".join(message.strip().lower().split()[:2]) == "meaning of":
        bot_response =  dictionary.meaning(" ".join(message.strip().lower().split()[2:]))
        if len (bot_response.keys()) == 0  :
            bot_response = "Sorry, Couldn't find the meaning "
        else:
            if 'Noun' in bot_response.keys():
                print bot_response['Noun'][0]
            else:
开发者ID:pipa0979,项目名称:HackCU2016,代码行数:33,代码来源:bot.py


注:本文中的PyDictionary.PyDictionary.antonym方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。