Skip to content
Extraits de code Groupes Projets
Valider 52cb4793 rédigé par pat's avatar pat
Parcourir les fichiers

integration of the tind fime (for iteration) in TextFST object

parent b7d50378
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -458,8 +458,6 @@ class TextFST: ...@@ -458,8 +458,6 @@ class TextFST:
self.__tfst = None self.__tfst = None
self.__tind = None self.__tind = None
self.__size = 0
def __del__(self): def __del__(self):
self.__tfst.close() self.__tfst.close()
...@@ -467,6 +465,8 @@ class TextFST: ...@@ -467,6 +465,8 @@ class TextFST:
return len(self.__tind) return len(self.__tind)
def __getitem__(self, i): def __getitem__(self, i):
if i >= len(self):
raise UnitexException("TextFST index out of range (size: %s)." % len(self))
position = self.__tind[i] position = self.__tind[i]
self.__tfst.seek(position) self.__tfst.seek(position)
...@@ -606,13 +606,6 @@ class TextFST: ...@@ -606,13 +606,6 @@ class TextFST:
encoding = UnitexConstants.DEFAULT_ENCODING encoding = UnitexConstants.DEFAULT_ENCODING
self.__tfst = open(fst, "r", encoding=encoding) self.__tfst = open(fst, "r", encoding=encoding)
line = self.__tfst.readline()
line = line.rstrip()
# The number of sentence in the text fst (format: '000000000N')
self.__size = int(line)
self.__tind = [] self.__tind = []
with open(index, "rb") as fin: with open(index, "rb") as fin:
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter