# 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_file(file, float_=False):
#     data = []
#     try:
#         with open(file, 'r') as datafile:
#             for line in datafile:
#                 content = line.strip('\n').split()
#                 if float_:
#                     content = [float(x) for x in content]
#                 data.append(content)
#     except Exception as e:
#         raise e
# 
#     return data
# 
# def dump_json(data, file):
#     try:
#         with open(file, 'w') as datafile:
#             json.dump(data, datafile)
#     except Exception as e:
#         raise e


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_file, dump_json
'''
Created on Jan, 2017

@author: hugo

'''
from __future__ import absolute_import


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('train_doc_codes', type=str, help='path to the train doc code file')
    parser.add_argument('train_doc_names', type=str, help='path to the train doc name file')
    parser.add_argument('val_doc_codes', type=str, help='path to the valid doc code file')
    parser.add_argument('val_doc_names', type=str, help='path to the valid doc name file')
    parser.add_argument('test_doc_codes', type=str, help='path to the test doc code file')
    parser.add_argument('test_doc_names', type=str, help='path to the test doc name file')
    parser.add_argument('out_dir', type=str, help='path to the output dir')
    args = parser.parse_args()

    train_doc_codes_path = args.train_doc_codes
    test_doc_codes_path = args.test_doc_codes
    train_doc_codes = load_file(train_doc_codes_path, True)
    train_doc_names = load_file(args.train_doc_names)
    val_doc_codes = load_file(args.val_doc_codes, True)

# 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_file(file, float_=False):
#     data = []
#     try:
#         with open(file, 'r') as datafile:
#             for line in datafile:
#                 content = line.strip('\n').split()
#                 if float_:
#                     content = [float(x) for x in content]
#                 data.append(content)
#     except Exception as e:
#         raise e
# 
#     return data
# 
# def dump_json(data, file):
#     try:
#         with open(file, 'w') as datafile:
#             json.dump(data, datafile)
#     except Exception as e:
#         raise e


# Path: docnade_doccodes_converter.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_file, dump_json

'''
Created on Jan, 2017

@author: hugo

'''
from __future__ import absolute_import


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('train_doc_codes', type=str, help='path to the train doc code file')
    parser.add_argument('train_doc_names', type=str, help='path to the train doc name file')
    parser.add_argument('val_doc_codes', type=str, help='path to the valid doc code file')
    parser.add_argument('val_doc_names', type=str, help='path to the valid doc name file')
    parser.add_argument('test_doc_codes', type=str, help='path to the test doc code file')
    parser.add_argument('test_doc_names', type=str, help='path to the test doc name file')
    parser.add_argument('out_dir', type=str, help='path to the output dir')
    args = parser.parse_args()

    train_doc_codes_path = args.train_doc_codes
    test_doc_codes_path = args.test_doc_codes
    train_doc_codes = load_file(train_doc_codes_path, True)
    train_doc_names = load_file(args.train_doc_names)
    val_doc_codes = load_file(args.val_doc_codes, True)

    val_doc_names = load_file(args.val_doc_names)