Esempio n. 1
0
def main(args):
    """
    calulate the number of times the words show up
    :return:
    """
    logging.info('starting words_tweeted')
    if not args.output_file:
        logging.error('no output file defined')
        sys.exit(-1)

    # create the counting structure
    wc = WordsCounter(args.output_file)

    # read file bringing the word list
    tfile = TweetFile(args.input_file)
    for words in tfile.get_words():

        # add each word in the dictionary
        wc.process_tweet(words)

    # save the info to output
    wc.write_results()
    logging.debug('Finished writing to %s' % args.output_file)

    # log the program is finished
    logging.info('program finished')
Esempio n. 2
0
def main(args):
    """
    Calculate the median of number of unique words
    :return:
    """
    logging.info('starting median_unique')
    if not args.output_file:
        logging.error('no output file defined')
        sys.exit(-1)

    # init vars
    mf = MedianFinder(args.output_file)

    # read file bringing the word list
    tfile = TweetFile(args.input_file)
    for words in tfile.get_words():
        # make an unique set of words and get its length
        mf.process_tweet(words)

        # save to file the current median
        mf.write_results()

    # log the program is finished
    logging.info('program finished')