new-words

changeset 45:5f90e44eecfc

new-words.py: turn words filtering and grouping on and off
author Igor Chubin <igor@chub.in>
date Fri Feb 04 06:18:50 2011 +0100 (2011-02-04)
parents 7eb1a8c3eade
children bf0aa8e3c1ce
files new-words-py.sh new-words.py
line diff
     1.1 --- a/new-words-py.sh	Fri Jan 28 21:45:58 2011 +0100
     1.2 +++ b/new-words-py.sh	Fri Feb 04 06:18:50 2011 +0100
     1.3 @@ -12,6 +12,7 @@
     1.4  
     1.5      -h          print this screen
     1.6      -c          show compressed wordlist: one word per group
     1.7 +    -G          turn off word grouping
     1.8      -k          put higher words that are similar to the known words (only for English)
     1.9      -l lang     override language settings
    1.10      -n          non-interactive mode (don't run vi)
    1.11 @@ -82,10 +83,12 @@
    1.12  FILTER_WORDS=YES
    1.13  SHOW_VOC_STAT=NO
    1.14  COMPRESSED_WORDLIST=NO
    1.15 -while getopts cl:sSkanNp:t:Tm:Mr:23 opt
    1.16 +WORDS_GROUPING=YES
    1.17 +while getopts Gcl:sSkanNp:t:Tm:Mr:23 opt
    1.18  do
    1.19      case "$opt" in
    1.20        c)  COMPRESSED_WORDLIST=YES;;
    1.21 +      G)  WORDS_GROUPING=NO;;
    1.22        s)  STAT_ONLY=YES;;
    1.23        S)  SHOW_VOC_STAT=YES;;
    1.24        k)  NEED_TO_USE_VOCABULARY_WHEN_SORT=YES;;
    1.25 @@ -141,6 +144,8 @@
    1.26      STAT_ONLY="$STAT_ONLY" \
    1.27      GROUP_WORDS_BY_TWO="$GROUP_WORDS_BY_TWO" \
    1.28      GROUP_WORDS_BY_THREE="$GROUP_WORDS_BY_THREE" \
    1.29 +    WORDS_GROUPING="$WORDS_GROUPING" \
    1.30 +    FILTER_WORDS="$FILTER_WORDS" \
    1.31      $NEW_WORDS_PY -l "$LANGUAGE" -f get_words_group_words_add_stat "$1"
    1.32  }
    1.33  
     2.1 --- a/new-words.py	Fri Jan 28 21:45:58 2011 +0100
     2.2 +++ b/new-words.py	Fri Feb 04 06:18:50 2011 +0100
     2.3 @@ -404,7 +404,8 @@
     2.4  
     2.5      stats = {}
     2.6      stats['total'] = sum(words[x] for x in words.keys())
     2.7 -    words = substract_dictionary(words, vocabulary)
     2.8 +    if 'FILTER_WORDS' in os.environ and os.environ['FILTER_WORDS'] == 'YES':
     2.9 +        words = substract_dictionary(words, vocabulary)
    2.10  
    2.11      stats['total_unknown'] = sum(words[x] for x in words.keys())
    2.12      stats['total_known'] = stats['total'] - stats['total_unknown']
    2.13 @@ -425,7 +426,8 @@
    2.14          words_with_freq.append((words[k], k))
    2.15  
    2.16      wgw = find_wordgroups_weights(words_with_freq, normalizator)
    2.17 -    words_with_freq = sorted(
    2.18 +    if 'WORDS_GROUPING' in os.environ and os.environ['WORDS_GROUPING'] == 'YES':
    2.19 +        words_with_freq = sorted(
    2.20                  words_with_freq,
    2.21                  cmp=lambda x,y:compare_word_pairs(x,y, wgw, normalizator, linked_words),
    2.22                  reverse=True)