drime

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

commit fe81b24132a9a162c58a30a73100bda85ea2e6dc
parent 11d1c425321e7d9d5f83e645b84e2d43b2c876ba
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Tue, 27 Dec 2011 02:47:07 +0100

more versatile

Diffstat:
query.py | 17++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/query.py b/query.py @@ -135,30 +135,33 @@ def do_query(word, phon, minsyll, maxsyll, elide, gender, offset, size): row['freq'] = float(row['freq']) row['phon_rhyme'] = lcs(phon, row['phon']) row['word_rhyme'] = lcs(word, row['word']) + bases = row['orig'].split(',') + for i in range(len(bases)): + bases[i] = bases[i].split('|') + row['orig'] = bases row['key'] = ( -row['phon_rhyme'], # phon_rhyme desc -row['word_rhyme'], # eye_rhyme desc - #TODO row['base'] != row['word'], # same as base + #-len([x for x in row['orig'] if x[1] == row['word']]), # same as base -row['freq'], # frequency desc row['word'] # alphabetical order ) + result.append(row) print ("DONE2") result2 = [] seen = set() for row in sorted(result, key=operator.itemgetter('key')): - bases = row['orig'].split(',') ok = False - for i in range(len(bases)): - bases[i] = bases[i].split('|') - if bases[i][1] not in seen: + for i in range(len(row['orig'])): + if row['orig'][i][1] not in seen: ok = True - seen.add(bases[i][1]) + seen.add(row['orig'][i][1]) if ok: row['orig'] = ', '.join( [a[0] + (' ('+a[1]+')' if row['word'] != a[1] else '') - for a in bases]) + for a in row['orig']]) row['phon'] = to_xsampa(row['phon']) result2.append(row) seen.add(row['word'])