<commit_before># -*- coding: utf-8 -*-
from synt.trainer import train
from synt.collector import collect, fetch
from synt.guesser import Guesser
from synt.tester import test

try:
    import argparse
except ImportError:
    raise

VERSION = '0.1.0'

def main():

    parser = argparse.ArgumentParser(description='Tool to interface with synt, provides a way to train, collect and guess from the command line.')

    subparsers = parser.add_subparsers(dest='parser')

    #Train Parser
    train_parser = subparsers.add_parser(
            'train', 
            help='Train a classifier.'
    )
    train_parser.add_argument(
        'db', 
        help="The name of the training database to use. They are stored/retreived from ~/.synt/"
    )
    train_parser.add_argument(
        'samples',
        type=int,
        help="The amount of samples to train on. Uses the samples.db",
    )
    train_parser.add_argument(
        '--classifier',
        default='naivebayes',
        choices=('naivebayes',),
        help="The classifier to use. We currently only support naivebayes.",
    )
    train_parser.add_argument(
        '--best_features',
        type=int,
        default=5000,
        help="The amount of best words to use, or best features. By default 5000 are used.",
    )
    train_parser.add_argument(
        '--purge',
        default='no',
        choices=('yes', 'no'),
        help="Yes to purge the redis database. By default no."
    ) 
    train_parser.add_argument(
        '--processes',
        default=4,
        help="Will utilize multiprocessing if available with this number of processes. By default 4."
    )

    #Collect parser
    collect_parser = subparsers.add_parser(
            'collect',
            help='Collect samples.'
    )
    collect_parser.add_argument(
        '--commit_every',
        default=200,
        type=int,
        help="Write to sqlite database after every 'this number'. Default is 200",
    )
    collect_parser.add_argument(
        '--max_collect',
        default=2000000,
        type=int,
        help="The amount to stop collecting at. Default is 2 million",
    )

    #Fetch parser
    fetch_parser = subparsers.add_parser(
            'fetch', 
            help='Fetches premade sample database.'
    )
    fetch_parser.add_argument(
            'db', 
            help="Fetches the default samples database from github and stores it as 'db' in ~/.synt/"
    )

    #Guess parser
    guess_parser = subparsers.add_parser(
            'guess',
            help='Guess sentiment'
    )
    guess_parser.add_argument(
        'guess', 
        nargs='?',
        default=True,
        help="Starts the guess prompt.",
    )
   
    #Tester parser
    tester_parser = subparsers.add_parser(
            'tester', 
            help='Test accuracy of classifier.',
    )
    tester_parser.add_argument(
        'samples', 
        type=int,
        help="The amount of samples to test on."
    )
    tester_parser.add_argument(
        '--classifier',
        default='naivebayes',
        choices=('naivebayes',),
        help="The classifier to use. Currently we only support naivebayes."
    )
    tester_parser.add_argument(
        '--neutral_range',
        default=0.0,
        type=float,
        help="Neutral range to use. By default there isn't one."
    )
   
    args = parser.parse_args()

    if args.parser == 'train':
        
        purge = False
        if not args.purge == 'no':
            purge = True

        train(
            db            = args.db,
            samples       = args.samples,
            classifier    = args.classifier,
            best_features = args.best_features,
            processes     = args.processes,
            purge         = purge,<commit_msg>parser train using redis_db<commit_after># -*- coding: utf-8 -*-
from synt.trainer import train
from synt.collector import collect, fetch
from synt.guesser import Guesser
from synt.tester import test

try:
    import argparse
except ImportError:
    raise

VERSION = '0.1.0'

def main():

    parser = argparse.ArgumentParser(description='Tool to interface with synt, provides a way to train, collect and guess from the command line.')

    subparsers = parser.add_subparsers(dest='parser')

    #Train Parser
    train_parser = subparsers.add_parser(
            'train', 
            help='Train a classifier.'
    )
    train_parser.add_argument(
        'db', 
        help="The name of the training database to use. They are stored/retreived from ~/.synt/"
    )
    train_parser.add_argument(
        'samples',
        type=int,
        help="The amount of samples to train on. Uses the samples.db",
    )
    train_parser.add_argument(
        '--classifier',
        default='naivebayes',
        choices=('naivebayes',),
        help="The classifier to use. See help for currently supported classifier.",
    )
    train_parser.add_argument(
        '--best_features',
        type=int,
        default=5000,
        help="The amount of best words to use, or best features. By default 5000 are used.",
    )
    train_parser.add_argument(
        '--purge',
        default='no',
        choices=('yes', 'no'),
        help="Yes to purge the redis database. By default no."
    ) 
    train_parser.add_argument(
        '--processes',
        default=4,
        help="Will utilize multiprocessing if available with this number of processes. By default 4."
    )
    train_parser.add_argument(
        '--redis_db',
        default = 5, 
        type=int,
        help="The redis db to use. By default 5",
    )

    #Collect parser
    collect_parser = subparsers.add_parser(
            'collect',
            help='Collect samples.'
    )
    collect_parser.add_argument(
        '--commit_every',
        default=200,
        type=int,
        help="Write to sqlite database after every 'this number'. Default is 200",
    )
    collect_parser.add_argument(
        '--max_collect',
        default=2000000,
        type=int,
        help="The amount to stop collecting at. Default is 2 million",
    )

    #Fetch parser
    fetch_parser = subparsers.add_parser(
            'fetch', 
            help='Fetches premade sample database.'
    )
    fetch_parser.add_argument(
            'db', 
            help="Fetches the default samples database from github and stores it as 'db' in ~/.synt/"
    )

    #Guess parser
    guess_parser = subparsers.add_parser(
            'guess',
            help='Guess sentiment'
    )
    guess_parser.add_argument(
        'guess', 
        nargs='?',
        default=True,
        help="Starts the guess prompt.",
    )
   
    #Tester parser
    tester_parser = subparsers.add_parser(
            'tester', 
            help='Test accuracy of classifier.',
    )
    tester_parser.add_argument(
        'samples', 
        type=int,
        help="The amount of samples to test on."
    )
    tester_parser.add_argument(
        '--classifier',
        default='naivebayes',
        choices=('naivebayes',),
        help="The classifier to use. Currently we only support naivebayes."
    )
    tester_parser.add_argument(
        '--neutral_range',
        default=0.0,
        type=float,
        help="Neutral range to use. By default there isn't one."
    )
   
    args = parser.parse_args()

    if args.parser == 'train':
        
        purge = False
        if not args.purge == 'no':
            purge = True

        train(
            db            = args.db,
            samples       = args.samples,
            classifier    = args.classifier,
            best_features = args.best_features,
            processes     = args.processes,
            purge         = purge,
            redis_db      = args.redis_db, 
{'fraction_non_alphanumeric': 0.10007737941707506, 'fraction_numerical': 0.007995873097755997, 'mean_word_length': 1.9475484606613456, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2436209', 'n_tokens_mistral': 2319, 'n_tokens_neox': 2218, 'n_words': 608}