@@ -63,7 +63,7 @@ def cache(transform, sentences):
63
63
fb = os .path .join (ftemp , os .path .basename (fbin ))
64
64
global flattened_fields
65
65
flattened_fields = self .flattened_fields
66
- binarize (sentences , fs )
66
+ binarize (progress_bar ( sentences ) , fs )
67
67
sentences = debinarize (fs , meta = True )
68
68
try :
69
69
yield ((sentences [s :s + chunksize ], ft , fs , f"{ fb } .{ i } " )
@@ -409,7 +409,7 @@ def load(
409
409
lines = (i for s in data for i in StringIO (self .toconll (s ) + '\n ' ))
410
410
411
411
index , sentence = 0 , []
412
- for line in progress_bar ( lines ) :
412
+ for line in lines :
413
413
line = line .strip ()
414
414
if len (line ) == 0 :
415
415
sentence = CoNLLSentence (self , sentence , index )
@@ -696,7 +696,7 @@ def load(
696
696
data = [data ] if isinstance (data [0 ], str ) else data
697
697
698
698
index = 0
699
- for s in progress_bar ( data ) :
699
+ for s in data :
700
700
try :
701
701
tree = nltk .Tree .fromstring (s ) if isinstance (s , str ) else self .totree (s , self .root )
702
702
sentence = TreeSentence (self , tree , index )
@@ -878,10 +878,11 @@ class TreeSentence(Sentence):
878
878
def __init__ (self , transform : Tree , tree : nltk .Tree , index : Optional [int ] = None ) -> TreeSentence :
879
879
super ().__init__ (transform , index )
880
880
881
- words , tags = zip (* tree .pos ())
882
- chart = [[None ]* (len (words )+ 1 ) for _ in range (len (words )+ 1 )]
883
- for i , j , label in Tree .factorize (Tree .binarize (tree )[0 ]):
884
- chart [i ][j ] = label
881
+ words , tags , chart = * zip (* tree .pos ()), None
882
+ if transform .training :
883
+ chart = [[None ]* (len (words )+ 1 ) for _ in range (len (words )+ 1 )]
884
+ for i , j , label in Tree .factorize (Tree .binarize (tree )[0 ]):
885
+ chart [i ][j ] = label
885
886
self .values = [words , tags , tree , chart ]
886
887
887
888
def __repr__ (self ):
0 commit comments