Commit e388a6af authored by Andreas Jung's avatar Andreas Jung

Strings were stored in the Lexicon using the intern() function

to provide some minor speedup. But this made it impossible to
store unicode strings. So we can now store unicode strings
in a Lexicon *yippi*
parent 28b832c1
...@@ -98,6 +98,7 @@ from BTrees.IOBTree import IOBTree ...@@ -98,6 +98,7 @@ from BTrees.IOBTree import IOBTree
from BTrees.IIBTree import IISet, IITreeSet from BTrees.IIBTree import IISet, IITreeSet
from randid import randid from randid import randid
from types import StringType
class Lexicon(Persistent, Implicit): class Lexicon(Persistent, Implicit):
"""Maps words to word ids and then some """Maps words to word ids and then some
...@@ -198,7 +199,11 @@ class Lexicon(Persistent, Implicit): ...@@ -198,7 +199,11 @@ class Lexicon(Persistent, Implicit):
while not inverse.insert(wid, word): while not inverse.insert(wid, word):
wid=randid() wid=randid()
if isinstance(word,StringType):
self._lexicon[intern(word)] = wid self._lexicon[intern(word)] = wid
else:
self._lexicon[word] = wid
return wid return wid
......
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