def get(word):
'''
make the word unique by appending a numbered suffix as necessary
:param word: such as 'foo'
:return: word with suffix such as 'foo_1'
'''
# global words
# if word not in words:
# words.add(word)
# return word
root = rootword(word) # word if len(chop)>1 and not chop[1].isdigit() else chop[0]
for n in itertools.count(1):
candidate = '%s_%d' % (root, n)
if candidate in words: continue
words.add(candidate)
return candidate
评论列表
文章目录