# Path: shorttext/utils/compactmodel_io.py
# class CompactIOMachine:
#     """ Base class that implements compact model I/O.
# 
#     This is to replace the original :func:`compactio` decorator.
# 
#     """
#     def __init__(self, infodict, prefix, suffices):
#         """
# 
#         :param infodict: information about the model. Must contain the key 'classifier'.
#         :param prefix: prefix of names of the model file
#         :param suffices: suffices of the names of the model file
#         :type infodict: dict
#         :type prefix: str
#         :type suffices: list
#         """
#         self.infodict = infodict
#         self.prefix = prefix
#         self.suffices = suffices
# 
#     def savemodel(self, nameprefix):
#         """ Abstract method for `savemodel`.
# 
#         :param nameprefix: prefix of the model path
#         :type nameprefix: str
#         """
#         raise e.OperationNotDefinedException()
# 
#     def loadmodel(self, nameprefix):
#         """ Abstract method for `loadmodel`.
# 
#         :param nameprefix: prefix of the model path
#         :type nameprefix: str
#         """
#         raise e.OperationNotDefinedException()
# 
#     def save_compact_model(self, filename, *args, **kwargs):
#         """ Save the model in a compressed binary format.
# 
#         :param filename: name of the model file
#         :param args: arguments
#         :param kwargs: arguments
#         :type filename: str
#         :type args: dict
#         :type kwargs: dict
#         """
#         save_compact_model(filename, self.savemodel, self.prefix, self.suffices, self.infodict, *args, **kwargs)
# 
#     def load_compact_model(self, filename, *args, **kwargs):
#         """ Load the model in a compressed binary format.
# 
#         :param filename: name of the model file
#         :param args: arguments
#         :param kwargs: arguments
#         :type filename: str
#         :type args: dict
#         :type kwargs: dict
#         """
#         return load_compact_model(filename, self.loadmodel, self.prefix, self.infodict, *args, **kwargs)
# 
#     def get_info(self):
#         """ Getting information for the dressed machine.
# 
#         :return: dictionary of the information for the dressed machine.
#         :rtype: dict
#         """
#         return {'classifier': self.infodict['classifier'],
#                 'prefix': self.prefix,
#                 'suffices': self.suffices}


import pickle
import numpy as np
import shorttext.utils.classification_exceptions as e
import shorttext.utils.kerasmodel_io as kerasio
from abc import ABC, abstractmethod
from keras.layers import Dense, Reshape
from keras.models import Sequential
from keras.regularizers import l2
from shorttext.utils.compactmodel_io import CompactIOMachine
    def score(self, shorttext, *args, **kwargs):
        """ Calculate the scores for each class labels.

        Not implemented. `NotImplemntedException` raised.

        :param shorttext: short text to be scored
        :param args: arguments to be parsed
        :param kwargs: arguments to be parsed
        :return: dictionary of scores for all class labels
        :type shorttext: str
        :type args: dict
        :type kwargs: dict
        :rtype: dict
        :raise: NotImplementedException
        """
        raise e.NotImplementedException()


class LogisticStackedGeneralization(StackedGeneralization, CompactIOMachine):
    """
    This class implements logistic regression as the stacked generalizer.

    It is an intermediate model
    that takes the results of other classifiers as the input features, and perform another classification.

    This class saves the stacked logistic model, but not the information of the primary model.

    The classifiers must have the :func:`~score` method that takes a string as an input argument.
    """
    def __init__(self, intermediate_classifiers={}):

# Path: shorttext/utils/compactmodel_io.py
# class CompactIOMachine:
#     """ Base class that implements compact model I/O.
# 
#     This is to replace the original :func:`compactio` decorator.
# 
#     """
#     def __init__(self, infodict, prefix, suffices):
#         """
# 
#         :param infodict: information about the model. Must contain the key 'classifier'.
#         :param prefix: prefix of names of the model file
#         :param suffices: suffices of the names of the model file
#         :type infodict: dict
#         :type prefix: str
#         :type suffices: list
#         """
#         self.infodict = infodict
#         self.prefix = prefix
#         self.suffices = suffices
# 
#     def savemodel(self, nameprefix):
#         """ Abstract method for `savemodel`.
# 
#         :param nameprefix: prefix of the model path
#         :type nameprefix: str
#         """
#         raise e.OperationNotDefinedException()
# 
#     def loadmodel(self, nameprefix):
#         """ Abstract method for `loadmodel`.
# 
#         :param nameprefix: prefix of the model path
#         :type nameprefix: str
#         """
#         raise e.OperationNotDefinedException()
# 
#     def save_compact_model(self, filename, *args, **kwargs):
#         """ Save the model in a compressed binary format.
# 
#         :param filename: name of the model file
#         :param args: arguments
#         :param kwargs: arguments
#         :type filename: str
#         :type args: dict
#         :type kwargs: dict
#         """
#         save_compact_model(filename, self.savemodel, self.prefix, self.suffices, self.infodict, *args, **kwargs)
# 
#     def load_compact_model(self, filename, *args, **kwargs):
#         """ Load the model in a compressed binary format.
# 
#         :param filename: name of the model file
#         :param args: arguments
#         :param kwargs: arguments
#         :type filename: str
#         :type args: dict
#         :type kwargs: dict
#         """
#         return load_compact_model(filename, self.loadmodel, self.prefix, self.infodict, *args, **kwargs)
# 
#     def get_info(self):
#         """ Getting information for the dressed machine.
# 
#         :return: dictionary of the information for the dressed machine.
#         :rtype: dict
#         """
#         return {'classifier': self.infodict['classifier'],
#                 'prefix': self.prefix,
#                 'suffices': self.suffices}


# Path: shorttext/stack/stacking.py
import pickle
import numpy as np
import shorttext.utils.classification_exceptions as e
import shorttext.utils.kerasmodel_io as kerasio
from abc import ABC, abstractmethod
from keras.layers import Dense, Reshape
from keras.models import Sequential
from keras.regularizers import l2
from shorttext.utils.compactmodel_io import CompactIOMachine

    def score(self, shorttext, *args, **kwargs):
        """ Calculate the scores for each class labels.

        Not implemented. `NotImplemntedException` raised.

        :param shorttext: short text to be scored
        :param args: arguments to be parsed
        :param kwargs: arguments to be parsed
        :return: dictionary of scores for all class labels
        :type shorttext: str
        :type args: dict
        :type kwargs: dict
        :rtype: dict
        :raise: NotImplementedException
        """
        raise e.NotImplementedException()


class LogisticStackedGeneralization(StackedGeneralization, CompactIOMachine):
    """
    This class implements logistic regression as the stacked generalizer.

    It is an intermediate model
    that takes the results of other classifiers as the input features, and perform another classification.

    This class saves the stacked logistic model, but not the information of the primary model.

    The classifiers must have the :func:`~score` method that takes a string as an input argument.
    """
    def __init__(self, intermediate_classifiers={}):

        CompactIOMachine.__init__(self,