From 24f2602711047289c53315ce8a59afe87db023bf Mon Sep 17 00:00:00 2001 From: rusinthread Date: Fri, 19 May 2017 00:10:02 +0300 Subject: Fix --- util.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'util.py') diff --git a/util.py b/util.py index 0b68a6c..8160a70 100644 --- a/util.py +++ b/util.py @@ -180,7 +180,7 @@ def split_sen(s, smart=True): s = s.strip() lines = [] - endings = ('. ', '? ', '! ') + endings = ('. ', '? ', '! ', '+') pos = 0 while pos < len(s): @@ -222,7 +222,7 @@ def split_sen(s, smart=True): return result_lines -def analyze_sentences(lines, not_used=False): +def analyze_sentences(lines, not_used=False, stats=True, space_output=False): max_len = 0 for line in lines: if len(line) > max_len: @@ -236,27 +236,30 @@ def analyze_sentences(lines, not_used=False): cprint('%2d. ' % i, 'cyan', end='') - print(line, end='') - if len(line) < max_len: - print(' ' * (max_len-len(line)), end='') - - cprint(str(len(words)), 'green', attrs=['bold'], end='') - cprint(' %s,' % plural(len(words), 'word words'), 'green', end='') + print(spaceitout(line, 0 if not space_output else 1), end='') + if stats: + if len(line) < max_len: + print(' ' * (max_len-len(line)), end='') + + cprint(str(len(words)), 'green', attrs=['bold'], end='') + cprint(' %s,' % plural(len(words), 'word words'), 'green', end='') - cprint(' %d' % len(line), 'yellow', attrs=['bold'], end='') - cprint('/', 'yellow', end='') - cprint('%d' % len(line.replace(' ', '')), 'yellow', attrs=['bold'], end='') + cprint(' %d' % len(line), 'yellow', attrs=['bold'], end='') + cprint('/', 'yellow', end='') + cprint('%d' % len(line.replace(' ', '')), 'yellow', attrs=['bold'], end='') - cprint(' chars ', 'yellow', end='') + cprint(' chars ', 'yellow', end='') - unique = unique_letters_amount(line) - cprint('(', 'red', end='') - cprint(unique, 'red', attrs=['bold'], end='') - cprint(' unique)', 'red') + unique = unique_letters_amount(line) + cprint('(', 'red', end='') + cprint(unique, 'red', attrs=['bold'], end='') + cprint(' unique)', 'red', end='') i += 1 + print() - cprint('Total unique characters: %d\n' % unique_letters_amount(''.join(lines)), 'white', attrs=['bold'], end='') + if stats: + cprint('Total unique characters: %d\n' % unique_letters_amount(''.join(lines)), 'white', attrs=['bold'], end='') if not_used: not_used_list = [] -- cgit v1.2.3