summaryrefslogtreecommitdiff
path: root/cli/commands/bridge/words.py
blob: 277b069f694761e8f2fd7c1ba991ff62a76d5786 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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))