本文整理匯總了Python中PyDictionary.PyDictionary方法的典型用法代碼示例。如果您正苦於以下問題:Python PyDictionary.PyDictionary方法的具體用法?Python PyDictionary.PyDictionary怎麽用?Python PyDictionary.PyDictionary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyDictionary
的用法示例。
在下文中一共展示了PyDictionary.PyDictionary方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: dictionary
# 需要導入模塊: import PyDictionary [as 別名]
# 或者: from PyDictionary import PyDictionary [as 別名]
def dictionary(self):
# Returns meaning, synonym and antonym of any word
Dict = PyDictionary()
print_say('\nEnter word', self)
word = raw_input()
print('\nMeaning : ' + str(Dict.googlemeaning(word)))
blockPrint()
syn = Dict.synonym(word)
ant = Dict.antonym(word)
if syn is not None:
syn = [x.encode('UTF8') for x in syn]
if ant is not None:
ant = [x.encode('UTF8') for x in ant]
enablePrint()
print('\nSynonyms : ' + str(syn))
print('\nAntonyms : ' + str(ant))
示例2: handle
# 需要導入模塊: import PyDictionary [as 別名]
# 或者: from PyDictionary import PyDictionary [as 別名]
def handle(text, mic, profile):
lst = text.split()
text = lst[len(lst)-1]
if(text):
dictionary=PyDictionary()
mean = dictionary.meaning(text)
if not mean:
mic.say("I'm sorry I couldn't find the meaning of the word "+text)
return
mic.say(text)
for keys in mean:
mic.say(keys)
lst = mean[keys]
for l in lst:
mic.say(l)
示例3: __init__
# 需要導入模塊: import PyDictionary [as 別名]
# 或者: from PyDictionary import PyDictionary [as 別名]
def __init__(self, bot):
self.bot = bot
self.dictionary = PyDictionary('lxml')
#TODO a query like 'a;lskejf;laskjf;lkjvldskjrlgjslfgnhslkfnhsoifjosijosjeojsopejr' gives a valid response with an unknown subject. UNKNOWN FIX
示例4: __init__
# 需要導入模塊: import PyDictionary [as 別名]
# 或者: from PyDictionary import PyDictionary [as 別名]
def __init__(self, bot):
self.bot = bot
self.dictionary = PyDictionary()
# self.lang = fileIO("data/dictionary/lang.json", "load")
示例5: define
# 需要導入模塊: import PyDictionary [as 別名]
# 或者: from PyDictionary import PyDictionary [as 別名]
def define(self, word: str):
dictionary = PyDictionary()
await self.bot.say(dictionary.meaning(word))
示例6: __init__
# 需要導入模塊: import PyDictionary [as 別名]
# 或者: from PyDictionary import PyDictionary [as 別名]
def __init__(self, *args, **kwargs):
super(SloganBot, self).__init__(*args, **kwargs)
twitter = None
only_twitter = "This bot publishes to Twitter and only Twitter."
if len(self.publishers) != 1:
raise Exception(only_twitter)
[publisher] = self.publishers
if publisher.service != 'twitter':
raise Exception(only_twitter)
self.twitter = publisher.api
self.dictionary = PyDictionary()
示例7: ex
# 需要導入模塊: import PyDictionary [as 別名]
# 或者: from PyDictionary import PyDictionary [as 別名]
def ex(dclient, private_channel, public_channel, mention, a, cmd_char):
a = a.split(' ')
if len(a) == 1:
word = a[0].lower()
pydict = PyDictionary()
r = pydict.meaning(word)
try:
an = '''```Markdown
# Meaning: {} #
'''.format(word)
if 'Noun' in r:
an += '''<Noun>
'''
cnt = 1
for d in r['Noun']:
an += '''[{}]: {}
'''.format(cnt, d)
cnt += 1
if 'Verb' in r:
an += '''<Verb>
'''
cnt = 1
for d in r['Verb']:
an += '''[{}]: {}
'''.format(cnt, d)
cnt += 1
if 'Adjective' in r:
an += '''<Adjective>
'''
cnt = 1
for d in r['Adjective']:
an += '''[{}]: {}
'''.format(cnt, d)
cnt += 1
an += '''```'''
await dclient.send_message(private_channel, an)
await dclient.send_message(public_channel, '{}, the meaning for the term `{}` has been sent in a private '
'message.'.format(mention, word))
except Exception:
await dclient.send_message(public_channel, '{}, there is no meaning for the term `{}`!'.format(mention,
word))
else:
await dclient.send_message(public_channel, '{}, **USAGE:** {}dictionary <term>'.format(mention, cmd_char))
示例8: buildUi
# 需要導入模塊: import PyDictionary [as 別名]
# 或者: from PyDictionary import PyDictionary [as 別名]
def buildUi(self):
global word
self.gridlayout = QtGui.QGridLayout()
title=QLabel()
titleFont = QtGui.QFont("Verdana", 12, QtGui.QFont.Bold)
title.setFont(titleFont)
title.setText(word.title())
title.setAlignment(QtCore.Qt.AlignHCenter)
self.gridlayout.addWidget(title)#,0,0,1,1)
l=QtGui.QTextEdit()
#font=QtGui.QFont()
#font.setFamily(_fromUtf8("Baskerville Old Face"))
# dictionary=PyDictionary()
# meanings=dictionary.meaning(word)
# Nouns=[]
# Verbs=[]
# for types in meanings:
# if types == "Noun":
# Nouns=meanings[u'Noun']
# elif types == "Verb":
# Verbs = meanings[u'Verb']
out = ""
# for x in meanings:
# out=out+'<b><font face="Comic sans MS" color="red">'+x.upper()+'</font></b><br/>'
# for y in meanings[x]:
# out=out+ '<br/><font face="Comic sans MS">• ' + y+'</font><br/>'
meanings = definition(word) # offline dict
if len(meanings) > 0:
for x in meanings:
x = '<b>' + x[:1] + '</b>' + x[1:]
out += x + '<br>'
else:
out = 'word not found'
out = '<font face="Comic sans MS">' + out + '</font>'
l.setHtml(out)
l.setReadOnly(True)
#l.setHtml("<h3> HEY </h3>")
#a = QtCore.QString('<b>HEY</b>')
#l.insertHtml(a)
#l.setPlainText(out)
self.gridlayout.addWidget(l)#,0,0,1,1)
self.setLayout(self.gridlayout)