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

Fix crashing index command when targeted directory contains subject files #705

Merged
merged 4 commits into from
May 16, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Rename vars to better correspond their origin/usage: keyfile(name) ->…
… subjfile(name)
  • Loading branch information
juhoinkinen committed May 15, 2023
commit b56b31e0c49e5b9270f5067af135a44536a2aa5e
8 changes: 4 additions & 4 deletions annif/corpus/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def __iter__(self):

@property
def documents(self):
for docfilename, keyfilename in self:
for docfilename, subjfilename in self:
with open(docfilename, errors="replace", encoding="utf-8-sig") as docfile:
text = docfile.read()
if keyfilename is None:
if subjfilename is None:
yield Document(text=text, subject_set=None)
continue
with open(keyfilename, encoding="utf-8-sig") as keyfile:
with open(subjfilename, encoding="utf-8-sig") as subjfile:
subjects = SubjectSet.from_string(
keyfile.read(), self.subject_index, self.language
subjfile.read(), self.subject_index, self.language
)
yield Document(text=text, subject_set=subjects)

Expand Down