Skip to content
Open
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
14 changes: 11 additions & 3 deletions neurox/data/extraction/transformers_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,19 @@ def extract_representations(
print("Reading input corpus")

def corpus_generator(input_corpus_path):
with open(input_corpus_path, "r") as fp:
for line in fp:
yield line.strip()
if not isinstance(input_corpus_path, list) and os.path.exists(input_corpus_path):
with open(input_corpus_path, "r") as fp:
for line in fp:
yield line.strip()
return
else:
if isinstance(input_corpus_path,str):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when is this condition used? do we expect the user to pass a single "sentence" as the input corpus?

input_corpus_path = [input_corpus_path]
for item in input_corpus_path:
yield item.strip()
return


print("Preparing output file")
writer = ActivationsWriter.get_writer(
output_file,
Expand Down