#!/usr/bin/env python3 # -*- coding: utf-8 -*- # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import argparse from stop_words import * from fileutils import * parser = argparse.ArgumentParser() parser.add_argument( 'files', metavar='file', nargs='+' ) parser.add_argument( '--force-html', default=False, action='store_true', help='Do not use file extension to determine format but force HTML instead.' ) parser.add_argument( '-v', '--verbose', default=False, action='store_true' ) args = parser.parse_args() texts = [open_file(filepath) for filepath in args.files] stop_words = find_stop_words(texts) if args.verbose: print('\n'.join(a+' '+str(b) for a, b in sorted((item for item in stop_words.items()), key=lambda x: (-x[1], x[0])))) else: print(' '.join(stop_words))