Commit 19586474 authored by Andreas Jung's avatar Andreas Jung

optimized the code to create digrams (10% performance gain)

parent 10077dad
......@@ -80,14 +80,9 @@ class GlobbingLexicon(Lexicon):
def createDigrams(self, word):
"""Returns a list with the set of digrams in the word."""
digrams = list(word)
digrams.append(self.eow)
last = self.eow
for i in range(len(digrams)):
last, digrams[i] = digrams[i], last + digrams[i]
return digrams
word = '$'+word+'$'
return [ word[i:i+2] for i in range(len(word)-1)]
def getWordId(self, word):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment