# HG changeset patch # User Igor Chubin # Date 1320332039 -3600 # Node ID 2a1a25e61872c34558ab48ef2c2956620d35dc7c # Parent e25de9ea918461c8a7ca83d9844b7ca16f239efd new-words.py can be used without wrapper; several features are not still implemented diff -r e25de9ea9184 -r 2a1a25e61872 new-words-py.sh --- a/new-words-py.sh Tue Nov 01 20:19:18 2011 +0100 +++ b/new-words-py.sh Thu Nov 03 15:53:59 2011 +0100 @@ -1,5 +1,11 @@ #!/bin/bash +cat < /dev/stderr @@ -134,6 +140,7 @@ { [ "$PART_TO_PROCESS" == "" ] || PART_TO_PROCESS="-p $PART_TO_PROCESS" [ "$ALLOWED_WORDS_FILENAME" = "" ] || ALLOWED_WORDS_FILENAME="-f $ALLOWED_WORDS_FILENAME" + [ "$SHOW_RANGE" = "" ] || SHOW_RANGE="-r $SHOW_RANGE" [ "$SHOW_RANGE_PERCENTAGE" = "" ] || SHOW_RANGE_PERCENTAGE="-R $SHOW_RANGE_PERCENTAGE" [ "$NON_INTERACTIVE_MODE" = YES ] && non_interactive="-n" [ "$STAT_ONLY" = YES ] && stat_only="-s" @@ -141,10 +148,10 @@ [ "$FILTER_WORDS" = NO ] && filter_words="-N" [ "$GROUP_WORDS_BY_TWO" = YES ] && group_words_by_two="-2" [ "$GROUP_WORDS_BY_THREE" = YES ] && group_words_by_three="-3" + [ "$WORDS_GROUPING" = NO ] && words_grouping="-G" - SHOW_RANGE="$SHOW_RANGE" \ - WORDS_GROUPING="$WORDS_GROUPING" \ $NEW_WORDS_PY -l "$LANGUAGE" \ + $SHOW_RANGE \ $SHOW_RANGE_PERCENTAGE \ $PART_TO_PROCESS \ $ALLOWED_WORDS_FILENAME \ @@ -154,6 +161,7 @@ $filter_words \ $group_words_by_two \ $group_words_by_three \ + $words_grouping \ -X get_words_group_words_add_stat "$1" } diff -r e25de9ea9184 -r 2a1a25e61872 new-words.py --- a/new-words.py Tue Nov 01 20:19:18 2011 +0100 +++ b/new-words.py Thu Nov 03 15:53:59 2011 +0100 @@ -119,7 +119,7 @@ parser.add_option( "-a", "--no-marks", - help="don't add marks (and don't save marks added by user)", + help="don't add marks (and don't save marks added by user) [NOT IMPLEMENTED YET]", action="store_true", dest="no_marks") @@ -148,6 +148,12 @@ dest="allowed_words") parser.add_option( + "-G", "--words-grouping", + help="turn off word grouping", + action="store_true", + dest="no_words_grouping") + +parser.add_option( "-X", "--function", help="filter through subsystem [INTERNAL]", action="store", @@ -155,13 +161,13 @@ parser.add_option( "-m", "--merge-tag", - help="merge words tagged with specified tag into the main vocabulary", + help="merge words tagged with specified tag into the main vocabulary [NOT IMPLEMENTED YET]", action="store", dest="merge_tag") parser.add_option( "-M", "--merge-tagged", - help="merge words tagged with ANY tag into the main vocabulary", + help="merge words tagged with ANY tag into the main vocabulary [NOT IMPLEMENTED YET]", action="store_true", dest="merge_tagged") @@ -190,6 +196,12 @@ dest="delete_tag") parser.add_option( + "-r", "--show-range", + help="show only words specified number of words", + action="store", + dest="show_range") + +parser.add_option( "-R", "--show-range-percentage", help="show only words that cover specified percentage of the text, skip the rest", action="store", @@ -203,7 +215,7 @@ parser.add_option( "-S", "--voc-stats", - help="show your vocabulary statistics (number of words and word groups)", + help="show your vocabulary statistics (number of words and word groups) [NOT IMPLEMENTED YET]", action="store_true", dest="voc_stats") @@ -539,7 +551,7 @@ def take_part(lines, part_description = None): - if part_description == None: + if part_description == None or part_description == '': return lines (start, stop, step) = parse_parts_description(part_description) n = len(lines) @@ -587,9 +599,8 @@ if 'compressed' in config: compressed_wordlist = True - show_range = os.environ.get('SHOW_RANGE', '') - if show_range != '': - show_range = int(show_range) + if 'show_range' in config: + show_range = int(config['show_range']) else: show_range = 0 @@ -637,7 +648,7 @@ words_with_freq.append((words[k], k)) wgw = find_wordgroups_weights(words_with_freq, normalizator) - if 'WORDS_GROUPING' in os.environ and os.environ['WORDS_GROUPING'] == 'YES': + if not 'no_words_grouping' in config or not config['no_words_grouping']: words_with_freq = sorted( words_with_freq, cmp=lambda x,y:compare_word_pairs(x,y, wgw, normalizator, linked_words), @@ -711,6 +722,9 @@ if options.allowed_words: config['allowed_words'] = options.allowed_words +if options.show_range: + config['show_range'] = options.show_range + if options.show_range_percentage: config['show_range_percentage'] = options.show_range_percentage @@ -732,17 +746,22 @@ if options.three_words: config['three_words'] = True -if options.function: - function_names = { - 'get_words_group_words_add_stat': filter_get_words_group_words_add_stat, - } - if options.function in function_names: - function_names[options.function](args) - else: - error_message("Unkown function %s.\nAvailable functions:\n%s" % ( - options.function, "".join([" "+x for x in sorted(function_names.keys())]))) - sys.exit(1) +if options.no_words_grouping: + config['no_words_grouping'] = True +filter_get_words_group_words_add_stat(args) + +#if options.function: +# function_names = { +# 'get_words_group_words_add_stat': , +# } +# if options.function in function_names: +# function_names[options.function](args) +# else: +# error_message("Unkown function %s.\nAvailable functions:\n%s" % ( +# options.function, "".join([" "+x for x in sorted(function_names.keys())]))) +# sys.exit(1) +#