# -*- coding: utf-8 -*-
import click
import logging
from pathlib import Path
from dotenv import find_dotenv, load_dotenv
from audio import signal, acoustic
from text import text
from data.dataset import get_dataset


@click.command()
@click.argument('features', type=str)
def main(features):
    logger = logging.getLogger(__name__)

    dataset = get_dataset()

    if features == 'audio.acoustic':
        acoustic.build_features(dataset)
    if features == 'audio.signal.vggish':
        signal.build_vggish_features(dataset)
    if features == 'text.tfidf':
        text.build_tfidf_features(dataset)
    if features == 'text.bow':
        text.build_bow_features(dataset)

    logger.info('Done')


if __name__ == '__main__':
    log_fmt = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    logging.basicConfig(level=logging.INFO, format=log_fmt)

    # not used in this stub but often useful for finding various files
    project_dir = Path(__file__).resolve().parents[2]

    # find .env automagically by walking up directories until it's found, then
    # load up the .env entries as environment variables
    load_dotenv(find_dotenv())

    main()
