Skip to content

Commit

Permalink
allow use of hyphens in vocabulary IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
osma committed Sep 2, 2022
1 parent 48b23f7 commit b9af8b2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
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

0 comments on commit b9af8b2

Please sign in to comment.