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): ...@@ -80,14 +80,9 @@ class GlobbingLexicon(Lexicon):
def createDigrams(self, word): def createDigrams(self, word):
"""Returns a list with the set of digrams in the 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)): word = '$'+word+'$'
last, digrams[i] = digrams[i], last + digrams[i] return [ word[i:i+2] for i in range(len(word)-1)]
return digrams
def getWordId(self, word): 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