drime

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

README (3633B)


      1 drime - by Antoine Amarilli
      2 A French rhyme dictionary
      3 Licence: GPL version 3
      4 
      5 
      6 == 1. Features ==
      7 
      8 drime is a French rhyme dictionary engine with advanced features, most
      9 notably rhyme selection based on phonetic or visual similarity,
     10 frequency, syllable count, and rhyme gender.
     11 
     12 == 2. Requirements ==
     13 
     14 drime requires a working Python3 installation.
     15 
     16 drime requires the haspirater module <https://a3nm.net/git/haspirater/>. Just
     17 place the "haspirater.py" and "haspirater.json" file in the same folder as the
     18 other files. It also requires the "rhyme.py", "options.py" and "vowels.py"
     19 modules from plint <https://a3nm.net/git/plint/> that you should put in the same
     20 folder, and also "frhyme.py" (see plint's documentation).
     21 
     22 drime also requires PyMySQL <http://www.pymysql.org> and Flask
     23 <http://flask.pocoo.org/> for Python3. To install PyMySQL, use for instance:
     24 
     25   sudo pip3 install pymysql
     26   sudo apt-get install python3-flask
     27 
     28 drime requires a working MySQL installation (package mysql-server on Debian
     29 systems) and the instructions in this README require the MySQL client (package
     30 mysql-client) to populate the database. You will probably want to create a
     31 database and a user for drime, probably along the lines of the following SQL
     32 commands executed using "mysql -u root -p":
     33 
     34   CREATE DATABASE drime;
     35   CREATE USER 'drime'@'localhost' IDENTIFIED BY 'mysecretpassword';
     36   GRANT ALL ON drime.* TO 'drime'@'localhost';
     37 
     38 == 3. Generating the DB ==
     39 
     40 The program database isn't shipped, but scripts are provided to build it
     41 from the Lexique3 database <http://lexique.org/>:
     42 
     43 - lexique_retrieve.sh retrieves a version of Lexique applies a few
     44   tweaks, and outputs it to stdout.
     45 
     46 - lexique2sql.sh takes the tweaked version of Lexique on stdin and produces
     47   the SQL database on stdout.
     48 
     49 You should therefore run:
     50 
     51   ./lexique_retrieve.sh | ./lexique2sql.sh > output.sql
     52 
     53 If this is not your first attempt, unzip might prompt you about overwriting
     54 existing files. Answer 'A'.
     55 
     56 To import the output of lexique2sql.sh in a MySQL database (on localhost,
     57 database 'drime', as user 'drime', interactive password authentication, the
     58 password being "mysecretpassword" if you followed the instructions of the
     59 previous section), run:
     60 
     61   cat output.sql |
     62     cat <(echo 'use drime;') - |
     63     cat - <(echo 'CREATE UNIQUE INDEX main ON words(word, phon);') |
     64     sed 's/varchar([0-9]*)/& collate utf8_bin/g' |
     65     mysql --default-character-set=utf8 -D drime -u drime -p
     66 
     67 To monitor progress, use the pv utility (replace "cat output.sql" by
     68 "pv -l output.sql").
     69 
     70 == 4. Using the DB ==
     71 
     72 == 4.1. Configuring database access ==
     73 
     74 Create a file with the connection parameters:
     75 
     76 cat > db_mysql_config.py <<EOF
     77 #!/usr/bin/python3 -O
     78 
     79 config = {
     80       'host': 'HOST',
     81       'user': 'USER',
     82       'passwd': 'PASSWD',
     83       'db': 'DB',
     84     }
     85 EOF
     86 
     87 == 4.2. Querying from the web ==
     88 
     89 To start the Flask development server, run:
     90 
     91   ./drime.py
     92 
     93 You can also deploy as WSGI with Apache2 using drime.wsgi. The configuration
     94 specifics are left as an unpleasant exercise to the reader.
     95 
     96 == 4.3. Querying from the command line ==
     97 
     98 Run:
     99 
    100   ./query.py QUERY [NSYL [GENDER [CLASSICAL [PAGE]]]]
    101 
    102 The parameters are the same as the four fields of the web interface, with the
    103 option to specify a page. For instance, to request rhymes for "chanter" with
    104 between 2-4 syllables, respecting genre but not classical constraints, run:
    105 
    106   ./query.py chanter 2-4 true true
    107 
    108 To get the second page of results, run:
    109 
    110   ./query.py chanter 2-4 true true 2
    111 
    112 Results are returned in a raw format (if the query is successful). To
    113 pretty-print, do:
    114 
    115   ./query.py bonjour | column -t -s '|'
    116