Closed optimisticninja closed 1 month ago
def get_entities(nums, delimiter):
texts = []
with open("./data/transcription.txt") as lp:
text = lp.read()
ends = list(find(text, delimiter))
for num in nums:
if num < 0 or num >= len(ends):
print(f"Warning: Entity index {num} is out of range.")
texts.append("")
else:
texts.append(text[0 if num == 0 else ends[num-1]:ends[num]])
return texts
def get_entities(nums, delimiter): texts = [] with open("./data/transcription.txt") as lp: text = lp.read() ends = list(find(text, delimiter)) for num in nums: if num < 0 or num >= len(ends): print(f"Warning: Entity index {num} is out of range.") texts.append("") else: texts.append(text[0 if num == 0 else ends[num-1]:ends[num]]) return texts
A nice way to warn on the issue, but it doesn't actually fix it. This would have too be fixed where it is being mutated.
This is likely happening when mode mutates and nums isn't updated as well, need to investigate. Semi-infrequent.