diff options
author | rusinthread <rusinthread@cock.li> | 2017-05-19 00:10:02 +0300 |
---|---|---|
committer | rusinthread <rusinthread@cock.li> | 2017-05-19 00:10:02 +0300 |
commit | 24f2602711047289c53315ce8a59afe87db023bf (patch) | |
tree | 4b090126f67d0d173f3c944db470f9e822dc9d51 /util.py | |
parent | d1a8d43887e3a390912c9ed6b82017433b6a565f (diff) |
Fix
Diffstat (limited to 'util.py')
-rw-r--r-- | util.py | 37 |
1 files changed, 20 insertions, 17 deletions
@@ -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 = [] |