Commit 57d7224e authored by Kathryn Elliott's avatar Kathryn Elliott

Changed to using argparse. Added logging.

* Changed code to add argparse for command line
parsing.
* Added logging handler to write INFO messages
or higher to standard error
parent fed05458
......@@ -3,11 +3,43 @@
import sys
import json
import pandas
import argparse
import logging
# https://docs.python.org/3/library/argparse.html
from pprint import pprint
from topic_model import TopicModel
# https://docs.python.org/3/howto/logging-cookbook.html
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M',
filename='topicModler.log',
filemode='w')
# define a Handler which writes INFO messages or higher to the sys.stderr
console = logging.StreamHandler()
console.setLevel(logging.WARNING)
# set a format which is simpler for console use
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
# tell the handler to use this format
console.setFormatter(formatter)
# add the handler to the root logger
logging.getLogger('').addHandler(console)
parser = argparse.ArgumentParser(description='Process some files.')
parser.add_argument('filenames', metavar='filename', type=str, nargs='+',
help='One or more files for the parser')
parser.add_argument('--min', type=int, default=5,
help='Setting the minimum topic count')
parser.add_argument('--max', type=int, default=20,
help='Setting the max topic count')
args = parser.parse_args()
logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d %(threadName)s %(message)s')
extra_stopwords = ['would', 'be', 're', 'edu', 'use', 'get', 'say', 'do', 'could']
extra_non_stopwords = ['to', 'go', 'not']
def load_data(dataset_file):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment