From bb5f8a9fe7f3968588b45eeaa0c993ef314ca904 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 1 Apr 2020 01:05:53 +0200 Subject: begin bridge --- cli/commands/api/category.py | 2 +- cli/commands/api/search.py | 2 +- cli/commands/bridge/words.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 cli/commands/bridge/words.py (limited to 'cli/commands') diff --git a/cli/commands/api/category.py b/cli/commands/api/category.py index 5b688f0..b5d1b84 100644 --- a/cli/commands/api/category.py +++ b/cli/commands/api/category.py @@ -8,7 +8,7 @@ import simplejson as json from app.thesaurus.api import Thesaurus @click.command() -@click.option('-c', '--id', 'opt_cat_id', required=True, +@click.option('-i', '--id', 'opt_cat_id', required=True, help='Category ID') @click.pass_context def cli(ctx, opt_cat_id): diff --git a/cli/commands/api/search.py b/cli/commands/api/search.py index 3c0dc0e..cdff053 100644 --- a/cli/commands/api/search.py +++ b/cli/commands/api/search.py @@ -8,7 +8,7 @@ import simplejson as json from app.thesaurus.api import Thesaurus @click.command() -@click.option('-w', '--word', 'opt_word', required=True, +@click.option('-i', '--word', 'opt_word', required=True, help='Word to search') @click.pass_context def cli(ctx, opt_word): diff --git a/cli/commands/bridge/words.py b/cli/commands/bridge/words.py new file mode 100644 index 0000000..277b069 --- /dev/null +++ b/cli/commands/bridge/words.py @@ -0,0 +1,30 @@ +""" +Find connections between two words +""" + +import click +import simplejson as json + +from app.thesaurus.api import Thesaurus + +@click.command() +@click.option('-a', '--a', 'opt_word_a', required=True, + help='Starting word') +@click.option('-b', '--b', 'opt_word_b', required=True, + help='Ending word') +@click.pass_context +def cli(ctx, opt_word_a, opt_word_b): + """Find connections between two words + """ + thesaurus = Thesaurus() + print(f"Starting word: {opt_word_a}") + print(f"Ending word: {opt_word_b}") + results_a = thesaurus.search(opt_word_a) + results_b = thesaurus.search(opt_word_b) + # use sets + # make set of results_a + # find overlap with results_b + # if there's no match... + # search for first word in results_a + # loop over results... + # print(json.dumps(results, indent=2)) -- cgit v1.2.3-70-g09d2