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

Allow use of hyphens in vocabulary IDs #619

Merged
merged 1 commit into from
Sep 2, 2022
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 annif/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_vocab(self, vocab_spec, default_language):
vocab_spec. If no language information is specified, use the given
default language."""

match = re.match(r'(\w+)(\((.*)\))?', vocab_spec)
match = re.match(r'([\w-]+)(\((.*)\))?$', vocab_spec)
if match is None:
raise ValueError(
f"Invalid vocabulary specification: {vocab_spec}")
Expand Down
2 changes: 1 addition & 1 deletion tests/projects.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ analyzer=snowball(english)
[noname]
language=en
backend=tfidf
vocab=dummy
vocab=dummy-noname
analyzer=snowball(english)

[noparams-tfidf-fi]
Expand Down
6 changes: 6 additions & 0 deletions tests/test_vocab.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ def test_get_vocab_invalid(registry):
assert 'Invalid vocabulary specification' in str(excinfo.value)


def test_get_vocab_hyphen(registry):
vocab, lang = registry.get_vocab('dummy-noname', None)
assert vocab.vocab_id == 'dummy-noname'
assert vocab is not None


def test_update_subject_index_with_no_changes(tmpdir):
vocab = load_dummy_vocab(tmpdir)

Expand Down