Skip to content

Commit

Permalink
Add learn CLI command
Browse files Browse the repository at this point in the history
  • Loading branch information
osma committed Feb 8, 2019
1 parent 84c9599 commit c8266cd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions annif/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ def run_train(project_id, paths):
proj.train(documents)


@cli.command('learn')
@click_log.simple_verbosity_option(logger)
@click.argument('project_id')
@click.argument('paths', type=click.Path(), nargs=-1)
def run_learn(project_id, paths):
"""
Further train an existing project on a collection of documents.
"""
proj = get_project(project_id)
documents = open_documents(paths)
proj.learn(documents)


@cli.command('analyze')
@click_log.simple_verbosity_option(logger)
@click.argument('project_id')
Expand Down
11 changes: 11 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ def test_train_multiple(testdatadir):
assert testdatadir.join('projects/tfidf-fi/tfidf-index').size() > 0


def test_learn(testdatadir):
docfile = os.path.join(
os.path.dirname(__file__),
'corpora',
'archaeology',
'documents.tsv')
result = runner.invoke(annif.cli.cli, ['learn', 'tfidf-fi', docfile])
assert not result.exception
assert result.exit_code == 0


def test_analyze():
result = runner.invoke(
annif.cli.cli,
Expand Down

0 comments on commit c8266cd

Please sign in to comment.