Skip to content

Commit

Permalink
skip sample if we hit a sample which has no content
Browse files Browse the repository at this point in the history
  • Loading branch information
Jemoka committed Oct 23, 2023
1 parent 1223a18 commit d0a8934
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions stanza/models/pos/data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from os import set_inheritable
import random
import logging
import torch
Expand Down Expand Up @@ -196,6 +197,13 @@ def __getitem__(self, key):
# get each character from the input sentnece
chars = [w for sent in char for w in sent]

# augmentation, etc. resulted in nothing; we return a different sample
if len(chars) == 0:
if key == 0:
return self[-1]
else:
return self[key-1]

return DataSample(words, chars, upos, xpos, ufeats, pretrained, sample[6]), key

def __iter__(self):
Expand Down

0 comments on commit d0a8934

Please sign in to comment.