Skip to content

Commit d93ca2b

Browse files
committed
Deal with use_vocab option
1 parent b34765d commit d93ca2b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

supar/utils/field.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,5 +362,7 @@ def build(self, dataset, min_freq=1):
362362

363363
def transform(self, charts):
364364
charts = [self.preprocess(chart) for chart in charts]
365-
charts = [torch.tensor([[self.vocab[i] if i is not None else -1 for i in row] for row in chart]) for chart in charts]
365+
if self.use_vocab:
366+
charts = [[[self.vocab[i] if i is not None else -1 for i in row] for row in chart] for chart in charts]
367+
charts = [torch.tensor(chart) for chart in charts]
366368
return charts

0 commit comments

Comments
 (0)