# Path: shorttext/utils/compactmodel_io.py
# def removedir(dir):
# def save_compact_model(filename, savefunc, prefix, suffices, infodict):
# def load_compact_model(filename, loadfunc, prefix, infodict):
#     def __init__(self, infodict, prefix, suffices):
#     def savemodel(self, nameprefix):
#     def loadmodel(self, nameprefix):
#     def save_compact_model(self, filename, *args, **kwargs):
#     def load_compact_model(self, filename, *args, **kwargs):
#     def get_info(self):
# def CompactIOClassifier(Classifier, infodict, prefix, suffices):
#         def save_compact_model(self, filename, *args, **kwargs):
#         def load_compact_model(self, filename, *args, **kwargs):
#         def get_info(self):
# def compactio(infodict, prefix, suffices):
# def get_model_config_field(filename, parameter):
# def get_model_classifier_name(filename):
# class CompactIOMachine:
#     class DressedClassifier(Classifier):


import json
import shorttext.utils.classification_exceptions as e
from keras.models import load_model
from keras.models import Model
from keras.layers import Input, LSTM, Dense
from shorttext.utils import compactmodel_io as cio
# Reference: https://blog.keras.io/a-ten-minute-introduction-to-sequence-to-sequence-learning-in-keras.html

kerasseq2seq_suffices = ['.h5', '.json', '_s2s_hyperparam.json', '_encoder.h5', '_encoder.json', '_decoder.h5', '_decoder.json']


class Seq2SeqWithKeras(cio.CompactIOMachine):
    """ Class implementing sequence-to-sequence (seq2seq) learning with keras.

    Reference:

    Ilya Sutskever, James Martens, Geoffrey Hinton, "Generating Text with Recurrent Neural Networks," *ICML* (2011). [`UToronto
    <http://www.cs.utoronto.ca/~ilya/pubs/2011/LANG-RNN.pdf>`_]

    Ilya Sutskever, Oriol Vinyals, Quoc V. Le, "Sequence to Sequence Learning with Neural Networks," arXiv:1409.3215 (2014). [`arXiv
    <https://arxiv.org/abs/1409.3215>`_]

    Francois Chollet, "A ten-minute introduction to sequence-to-sequence learning in Keras," *The Keras Blog*. [`Keras
    <https://blog.keras.io/a-ten-minute-introduction-to-sequence-to-sequence-learning-in-keras.html>`_]

    Aurelien Geron, *Hands-On Machine Learning with Scikit-Learn and TensorFlow* (Sebastopol, CA: O'Reilly Media, 2017). [`O\'Reilly
    <http://shop.oreilly.com/product/0636920052289.do>`_]
    """
    def __init__(self, vecsize, latent_dim):
        """ Instantiate the class.

        :param vecsize: vector size of the sequence
        :param latent_dim: latent dimension in the RNN cell
        :type vecsize: int
        :type latent_dim: int
        """

# Path: shorttext/utils/compactmodel_io.py
# def removedir(dir):
# def save_compact_model(filename, savefunc, prefix, suffices, infodict):
# def load_compact_model(filename, loadfunc, prefix, infodict):
#     def __init__(self, infodict, prefix, suffices):
#     def savemodel(self, nameprefix):
#     def loadmodel(self, nameprefix):
#     def save_compact_model(self, filename, *args, **kwargs):
#     def load_compact_model(self, filename, *args, **kwargs):
#     def get_info(self):
# def CompactIOClassifier(Classifier, infodict, prefix, suffices):
#         def save_compact_model(self, filename, *args, **kwargs):
#         def load_compact_model(self, filename, *args, **kwargs):
#         def get_info(self):
# def compactio(infodict, prefix, suffices):
# def get_model_config_field(filename, parameter):
# def get_model_classifier_name(filename):
# class CompactIOMachine:
#     class DressedClassifier(Classifier):


# Path: shorttext/generators/seq2seq/s2skeras.py
import json
import shorttext.utils.classification_exceptions as e
from keras.models import load_model
from keras.models import Model
from keras.layers import Input, LSTM, Dense
from shorttext.utils import compactmodel_io as cio

# Reference: https://blog.keras.io/a-ten-minute-introduction-to-sequence-to-sequence-learning-in-keras.html

kerasseq2seq_suffices = ['.h5', '.json', '_s2s_hyperparam.json', '_encoder.h5', '_encoder.json', '_decoder.h5', '_decoder.json']


class Seq2SeqWithKeras(cio.CompactIOMachine):
    """ Class implementing sequence-to-sequence (seq2seq) learning with keras.

    Reference:

    Ilya Sutskever, James Martens, Geoffrey Hinton, "Generating Text with Recurrent Neural Networks," *ICML* (2011). [`UToronto
    <http://www.cs.utoronto.ca/~ilya/pubs/2011/LANG-RNN.pdf>`_]

    Ilya Sutskever, Oriol Vinyals, Quoc V. Le, "Sequence to Sequence Learning with Neural Networks," arXiv:1409.3215 (2014). [`arXiv
    <https://arxiv.org/abs/1409.3215>`_]

    Francois Chollet, "A ten-minute introduction to sequence-to-sequence learning in Keras," *The Keras Blog*. [`Keras
    <https://blog.keras.io/a-ten-minute-introduction-to-sequence-to-sequence-learning-in-keras.html>`_]

    Aurelien Geron, *Hands-On Machine Learning with Scikit-Learn and TensorFlow* (Sebastopol, CA: O'Reilly Media, 2017). [`O\'Reilly
    <http://shop.oreilly.com/product/0636920052289.do>`_]
    """
    def __init__(self, vecsize, latent_dim):
        """ Instantiate the class.

        :param vecsize: vector size of the sequence
        :param latent_dim: latent dimension in the RNN cell
        :type vecsize: int
        :type latent_dim: int
        """

        cio.CompactIOMachine.__init__(self, {'classifier': 'kerasseq2seq'}, 'kerasseq2seq', kerasseq2seq_suffices)