本文整理汇总了Python中pattern.Pattern.getPatternCode方法的典型用法代码示例。如果您正苦于以下问题:Python Pattern.getPatternCode方法的具体用法?Python Pattern.getPatternCode怎么用?Python Pattern.getPatternCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pattern.Pattern
的用法示例。
在下文中一共展示了Pattern.getPatternCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unicode
# 需要导入模块: from pattern import Pattern [as 别名]
# 或者: from pattern.Pattern import getPatternCode [as 别名]
minDistance = 1000
word_u = unicode(word)
for wazn in templates:
wazn_u = unicode(wazn)
distanceI = distance(word_u, wazn_u)
if distanceI < minDistance:
minDistance = distanceI
template = wazn
continue
if distanceI == minDistance:
template = template + '+' + wazn
if not '+' in template:
template = template + ";"
return template
def getTemplate(word):
template = getTemplateNoDiac(word)
if not '+' in template:
return template
return getTemplateFromList(word, template)
if __name__ == '__main__':
from pattern import Pattern
import sys
from sys import argv
script, word = argv
word = unicode(word, 'utf-8')
wordpat = Pattern(word)
print wordpat.getPatternCode()
print wordpat.getUnvocalized()