# Path: autoencoder/preprocessing/preprocessing.py
# def load_corpus(corpus_path):
#     corpus = load_json(corpus_path)
# 
#     return corpus
# 
# def doc2vec(doc, dim):
#     vec = np.zeros(dim)
#     for idx, val in doc.items():
#         vec[int(idx)] = val
# 
#     return vec
# 
# 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
# 
# def dump_pickle(data, path_to_file):
#     try:
#         with open(path_to_file, 'w') as f:
#             pickle.dump(data, f)
#     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, doc2vec
from autoencoder.utils.io_utils import load_json, dump_pickle
'''
Created on Jan, 2017

@author: hugo

'''
from __future__ import absolute_import


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('corpus', type=str, help='path to the corpus file')
    parser.add_argument('labels', type=str, help='path to the labels file')
    parser.add_argument('-bs', '--batch_size', type=int, default=100, help='batch size (default 100)')
    parser.add_argument('out_dir', type=str, help='path to the output dir')
    args = parser.parse_args()

    corpus = load_corpus(args.corpus)
    doc_labels = load_json(args.labels)
    vocab, docs = corpus['vocab'], corpus['docs']
    n_vocab = len(vocab)
    doc_names = docs.keys()

# Path: autoencoder/preprocessing/preprocessing.py
# def load_corpus(corpus_path):
#     corpus = load_json(corpus_path)
# 
#     return corpus
# 
# def doc2vec(doc, dim):
#     vec = np.zeros(dim)
#     for idx, val in doc.items():
#         vec[int(idx)] = val
# 
#     return vec
# 
# 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
# 
# def dump_pickle(data, path_to_file):
#     try:
#         with open(path_to_file, 'w') as f:
#             pickle.dump(data, f)
#     except Exception as e:
#         raise e


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

'''
Created on Jan, 2017

@author: hugo

'''
from __future__ import absolute_import


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('corpus', type=str, help='path to the corpus file')
    parser.add_argument('labels', type=str, help='path to the labels file')
    parser.add_argument('-bs', '--batch_size', type=int, default=100, help='batch size (default 100)')
    parser.add_argument('out_dir', type=str, help='path to the output dir')
    args = parser.parse_args()

    corpus = load_corpus(args.corpus)
    doc_labels = load_json(args.labels)
    vocab, docs = corpus['vocab'], corpus['docs']
    n_vocab = len(vocab)
    doc_names = docs.keys()

    X_docs = [doc2vec(x, n_vocab) for x in docs.values()]