#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import markovchain
from optparse import OptionParser

usage = "markov [options] corpus1 corpus2 ..."

parser = OptionParser()
parser.add_option("-l", "--lookback", dest="lookback",
                  help="number of characters to look back in the chain", metavar="LOOKBACK", default=2)
parser.add_option("-d", "--dictionary", dest="dictionary",
                  help="dictionary file to use", metavar="DICTIONARY", default='small_dict.txt')
parser.add_option("-n", "--name", dest="name",
                  help="Name of the language, if this is set, the output will go into a file")

(options, args) = parser.parse_args()
if (len(args) == 0):
  print(usage)
  exit()
if (options.name):
  target = open(options.name + ".csv", 'w')
  target.write(str(markovchain.MarkovChain(args, options.dictionary, int(options.lookback))))

else:
  print(markovchain.MarkovChain(args, options.dictionary, int(options.lookback)))
