Skip to content

Commit

Permalink
pretty print on command cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Arian Pasquali committed Mar 11, 2019
1 parent b66928b commit 37f556d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
@@ -1,7 +1,8 @@
tabulate
pytest
flake8
segtok
jellyfish
networkx
numpy
click
click
10 changes: 7 additions & 3 deletions yake/cli.py
Expand Up @@ -4,6 +4,7 @@

import click
import yake
from tabulate import tabulate

@click.command()
@click.option("-ti",'--text_input', help='Input text, SURROUNDED by single quotes(\')', required=False)
Expand All @@ -25,11 +26,14 @@ def run_yake(text_content):
windowsSize=window_size, top=top)
results = myake.extract_keywords(text_content)

table = []
for kw in results:
if (verbose):
print(kw[0], kw[1])
table.append({"keyword":kw[0], "score":kw[1]})
else:
print(kw[1])
table.append({"keyword":kw[0]})

print(tabulate(table, headers="keys"))

if text_input and input_file:
print("You should specify either an input file or direct text input, but not both!")
Expand All @@ -46,4 +50,4 @@ def run_yake(text_content):
run_yake(text_content)

if __name__ == "__main__":
main()
keywords()

0 comments on commit 37f556d

Please sign in to comment.