#!/usr/bin/env python

from __future__ import print_function

"""
A script to parse using corpkit

:Example:

parse junglebook --speaker-segmentation True

"""

import sys
from corpkit import Corpus

if len(sys.argv) == 1:
    raise ValueError('Please specify a corpus to parse.')

trans = {'true': True,
         'false': False,
         'none': None}

corp = Corpus(sys.argv[1])
kwargs = {}
args = sys.argv[2:]
for index, item in enumerate(args):
    if item.startswith('-'):
        item = item.lstrip('-').lower().replace('-', '_')
        if '=' in item:
            val = item.split('=', 1)[1]
        else:
            val = args[index+1]
        if val.isdigit():
            val = int(val)
        if isinstance(val, str):
            val = trans.get(val.lower(), val)
        kwargs[item] = val

parsed = corp.parse(**kwargs)


