Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-3267: Fix false warning for "An empty Sentence was created!" #3268

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flair/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ def __str__(self) -> str:
f"{len(self.dev) if self.dev else 0} dev + "
f"{len(self.test) if self.test else 0} test sentences\n - "
)
output += "\n - ".join([f"{type(corpus).__name__} {str(corpus)} - {corpus.name}" for corpus in self.corpora])
output += "\n - ".join([f"{type(corpus).__name__} {corpus!s} - {corpus.name}" for corpus in self.corpora])
return output


Expand Down
8 changes: 5 additions & 3 deletions flair/datasets/sequence_labeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,11 @@ def _identify_span_columns(self, column_name_map, skip_first_line):
# check the first 5 sentences
probe = []
for _i in range(5):
sentence = self._convert_lines_to_sentence(
self._read_next_sentence(file), word_level_tag_columns=column_name_map
)
next_sentence = self._read_next_sentence(file)
if len(next_sentence) == 0:
break

sentence = self._convert_lines_to_sentence(next_sentence, word_level_tag_columns=column_name_map)
if sentence:
probe.append(sentence)
else:
Expand Down
4 changes: 2 additions & 2 deletions flair/inference_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def __init__(self, embedding, verbose) -> None:
self.k = len(result[0]) - 1
return
except sqlite3.Error as err:
logger.exception(f"Fail to open sqlite database {self.store_path!s}: {str(err)}")
logger.exception(f"Fail to open sqlite database {self.store_path!s}: {err!s}")
# otherwise, push embedding to database
if hasattr(embedding, "precomputed_word_embeddings"):
self.db = sqlite3.connect(str(self.store_path))
Expand Down Expand Up @@ -239,7 +239,7 @@ def __init__(self, embedding, verbose) -> None:
cursor.close()
return
except lmdb.Error as err:
logger.exception(f"Fail to open lmdb database {self.store_path!s}: {str(err)}")
logger.exception(f"Fail to open lmdb database {self.store_path!s}: {err!s}")
# create and load the database in write mode
if hasattr(embedding, "precomputed_word_embeddings"):
pwe = embedding.precomputed_word_embeddings
Expand Down