drime

French rhyme dictionary with web and CLI interface
git clone https://a3nm.net/git/drime/
Log | Files | Refs | README

commit d28f7ef401b5a6a992b93b47e2dedf9eda78f886
parent e01ddcf8c5218bab17ccd41ce6fda6674ce20b36
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Fri, 30 Dec 2011 14:38:30 +0100

improve cli interface

Diffstat:
README | 8++++++--
query.py | 11++++++++++-
2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/README b/README @@ -73,6 +73,10 @@ Run: ./query.py QUERY [NSYL [GENDER]] -For documentation, see the web interface. The results are returned as JSON. -(This is a work in progress.) +The parameters are the same as the three fields of the web interface. + +Results are returned in a raw format (if the query is successful). To +pretty-print, do: + + ./query.py bonjour | column -t -s '|' diff --git a/query.py b/query.py @@ -191,5 +191,14 @@ if __name__ == '__main__': print (" - %s" % k[2]) print ("Please rerun with a more specific query") sys.exit(2) - print(json.dumps(r['result'], indent=4)) + result = [["word", "phon", "pr", "wr", "freq", "orig"]] + [ + (x['word'], + x['phon'], + str(x['phon_rhyme']), + str(x['word_rhyme']), + str(x['freq']), + x['orig']) for x in r['result']] + #print ("Displaying result for %s" % r['keys'][0][2]) + for x in result: + print '|'.join([y.encode('utf-8') for y in x])