Skip to content

Commit

Permalink
GH-798: skip sentences without labels in CSV reader
Browse files Browse the repository at this point in the history
  • Loading branch information
aakbik committed Jun 24, 2019
1 parent 6e96d78 commit 1c5fccf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions flair/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,22 @@ def __init__(

for row in csv_reader:

# test if format is OK
wrong_format = False
for text_column in self.text_columns:
if text_column >= len(row):
wrong_format = True

# test if at least one label given
has_label = False
for column in self.column_name_map:
if self.column_name_map[column].startswith("label") and row[column]:
has_label = True
break

if wrong_format or not has_label:
continue

if self.in_memory:

text = " || ".join(
Expand Down

0 comments on commit 1c5fccf

Please sign in to comment.