# Path: autoencoder/preprocessing/preprocessing.py
# def load_corpus(corpus_path):
#     corpus = load_json(corpus_path)
# 
#     return corpus
# 
# def corpus2libsvm(docs, doc_labels, output):
#     '''Convert the corpus format to libsvm format.
#     '''
#     data = []
#     names = []
#     for key, val in docs.iteritems():
#         # label = doc_labels[key]
#         label = 0
#         line = label if isinstance(label, list) else [str(label)] + ["%s:%s" % (int(x) + 1, y) for x, y in val.iteritems()]
#         data.append(line)
#         names.append(key)
#     write_file(data, output)
#     write_file(names, output + '.fnames')
#     return data, names
# 
# Path: autoencoder/utils/io_utils.py
# def load_json(file):
#     try:
#         with open(file, 'r') as datafile:
#             data = json.load(datafile)
#     except Exception as e:
#         raise e
# 
#     return data


import os
import sys
import argparse
import numpy as np
    import pdb;pdb.set_trace()
from autoencoder.preprocessing.preprocessing import load_corpus, corpus2libsvm
from autoencoder.utils.io_utils import load_json
'''
Created on Jan, 2017

@author: hugo

'''
from __future__ import absolute_import


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('train_path', type=str, help='path to the train corpus file')
    parser.add_argument('test_path', type=str, help='path to the test corpus file')
    parser.add_argument('train_label', type=str, help='path to the train label file')
    parser.add_argument('test_label', type=str, help='path to the test label file')
    parser.add_argument('out_dir', type=str, help='path to the output dir')
    parser.add_argument('-nv', '--n_val', type=int, default=1000, help='validation set size')
    args = parser.parse_args()

    docs = load_corpus(args.train_path)['docs'].items()

# Path: autoencoder/preprocessing/preprocessing.py
# def load_corpus(corpus_path):
#     corpus = load_json(corpus_path)
# 
#     return corpus
# 
# def corpus2libsvm(docs, doc_labels, output):
#     '''Convert the corpus format to libsvm format.
#     '''
#     data = []
#     names = []
#     for key, val in docs.iteritems():
#         # label = doc_labels[key]
#         label = 0
#         line = label if isinstance(label, list) else [str(label)] + ["%s:%s" % (int(x) + 1, y) for x, y in val.iteritems()]
#         data.append(line)
#         names.append(key)
#     write_file(data, output)
#     write_file(names, output + '.fnames')
#     return data, names
# 
# Path: autoencoder/utils/io_utils.py
# def load_json(file):
#     try:
#         with open(file, 'r') as datafile:
#             data = json.load(datafile)
#     except Exception as e:
#         raise e
# 
#     return data


# Path: corpus2libsvm.py
import os
import sys
import argparse
import numpy as np
    import pdb;pdb.set_trace()
from autoencoder.preprocessing.preprocessing import load_corpus, corpus2libsvm
from autoencoder.utils.io_utils import load_json

'''
Created on Jan, 2017

@author: hugo

'''
from __future__ import absolute_import


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('train_path', type=str, help='path to the train corpus file')
    parser.add_argument('test_path', type=str, help='path to the test corpus file')
    parser.add_argument('train_label', type=str, help='path to the train label file')
    parser.add_argument('test_label', type=str, help='path to the test label file')
    parser.add_argument('out_dir', type=str, help='path to the output dir')
    parser.add_argument('-nv', '--n_val', type=int, default=1000, help='validation set size')
    args = parser.parse_args()

    docs = load_corpus(args.train_path)['docs'].items()

    test_docs = load_corpus(args.test_path)['docs']