本文整理汇总了Python中UI.request_x方法的典型用法代码示例。如果您正苦于以下问题:Python UI.request_x方法的具体用法?Python UI.request_x怎么用?Python UI.request_x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UI
的用法示例。
在下文中一共展示了UI.request_x方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: xhyper
# 需要导入模块: import UI [as 别名]
# 或者: from UI import request_x [as 别名]
def xhyper(words)->[str]:
'''returns the highest order x hypernyms'''
x = UI.request_x()
print("\nNote: this program will use the first parallel synset if there are any")
print("\nGathering data...")
result = [x]
hyp = lambda w: w.hypernyms()
#This would pick up the deepest branch's depth -> valueAt returns None -> returns None
#depth = lambda L: isinstance(L, list) and max(map(depth, L))+1
for i in range(len(words)):
synsets = wordnet.synsets(words[i])
if len(synsets) > 0:
for s in range(len(synsets)):
hyper = wordnet.synsets(words[i])[s].tree(hyp)
if (hyper[0].pos() in ['a','s','r']):
result.append([words[i], 'None', 'None', [None]])
continue
d = first_depth(hyper) - 1
xhyper = []
for j in range(x):
xhyper.append(valueAt(d - j, hyper))
if xhyper[-1] is None:
break
result.append([words[i], pos_redef(hyper[0].pos()), hyper[0], xhyper])
else:
result.append([words[i], 'None', 'None', [None]])
return result