# Path: shorttext/utils/textpreprocessing.py
# def preprocess_text(text, pipeline):
# def text_preprocessor(pipeline):
# def oldschool_standard_text_preprocessor(stopwordsfile):
# def standard_text_preprocessor_1():
# def standard_text_preprocessor_2():
# 
# Path: shorttext/utils/gensim_corpora.py
# def generate_gensim_corpora(classdict, preprocess_and_tokenize=tokenize):
# def save_corpus(dictionary, corpus, prefix):
# def load_corpus(prefix):
# def update_corpus_labels(dictionary, corpus, newclassdict, preprocess_and_tokenize=tokenize):
# def tokens_to_fracdict(tokens):
# 
# Path: shorttext/utils/classification_exceptions.py
# class ModelNotTrainedException(Exception):
# class AlgorithmNotExistException(Exception):
# class WordEmbeddingModelNotExistException(Exception):
# class UnequalArrayLengthsException(Exception):
# class NotImplementedException(Exception):
# class IncorrectClassificationModelFileException(Exception):
# class OperationNotDefinedException(Exception):
#     def __init__(self):
#     def __init__(self, algoname):
#     def __init__(self, path):
#     def __init__(self, arr1, arr2):
#     def __init__(self):
#     def __init__(self, expectedname, actualname):
#     def __init__(self, opname):
# 
# Path: shorttext/utils/textpreprocessing.py
# def preprocess_text(text, pipeline):
# def text_preprocessor(pipeline):
# def oldschool_standard_text_preprocessor(stopwordsfile):
# def standard_text_preprocessor_1():
# def standard_text_preprocessor_2():


from abc import ABC, abstractmethod
from shorttext.utils import textpreprocessing as textpreprocess, gensim_corpora as gc, classification_exceptions as e
from shorttext.utils.textpreprocessing import tokenize
import numpy as np


# abstract class
class LatentTopicModeler(ABC):
    """
    Abstract class for various topic modeler.
    """
    def __init__(self,
                 preprocessor=textpreprocess.standard_text_preprocessor_1(),
                 normalize=True):
        """ Initialize the modeler.

        :param preprocessor: function that preprocesses the text. (Default: `shorttext.utils.textpreprocess.standard_text_preprocessor_1`)
        :param normalize: whether the retrieved topic vectors are normalized. (Default: True)
        :type preprocessor: function
        :type normalize: bool
        """
        self.preprocessor = preprocessor
        self.normalize = normalize
        self.trained = False

    def generate_corpus(self, classdict):
        """ Calculate the gensim dictionary and corpus, and extract the class labels
        from the training data. Called by :func:`~train`.

        :param classdict: training data
        :return: None
        :type classdict: dict
        """
        self.dictionary, self.corpus, self.classlabels = gc.generate_gensim_corpora(classdict,

# Path: shorttext/utils/textpreprocessing.py
# def preprocess_text(text, pipeline):
# def text_preprocessor(pipeline):
# def oldschool_standard_text_preprocessor(stopwordsfile):
# def standard_text_preprocessor_1():
# def standard_text_preprocessor_2():
# 
# Path: shorttext/utils/gensim_corpora.py
# def generate_gensim_corpora(classdict, preprocess_and_tokenize=tokenize):
# def save_corpus(dictionary, corpus, prefix):
# def load_corpus(prefix):
# def update_corpus_labels(dictionary, corpus, newclassdict, preprocess_and_tokenize=tokenize):
# def tokens_to_fracdict(tokens):
# 
# Path: shorttext/utils/classification_exceptions.py
# class ModelNotTrainedException(Exception):
# class AlgorithmNotExistException(Exception):
# class WordEmbeddingModelNotExistException(Exception):
# class UnequalArrayLengthsException(Exception):
# class NotImplementedException(Exception):
# class IncorrectClassificationModelFileException(Exception):
# class OperationNotDefinedException(Exception):
#     def __init__(self):
#     def __init__(self, algoname):
#     def __init__(self, path):
#     def __init__(self, arr1, arr2):
#     def __init__(self):
#     def __init__(self, expectedname, actualname):
#     def __init__(self, opname):
# 
# Path: shorttext/utils/textpreprocessing.py
# def preprocess_text(text, pipeline):
# def text_preprocessor(pipeline):
# def oldschool_standard_text_preprocessor(stopwordsfile):
# def standard_text_preprocessor_1():
# def standard_text_preprocessor_2():


# Path: shorttext/generators/bow/LatentTopicModeling.py
from abc import ABC, abstractmethod
from shorttext.utils import textpreprocessing as textpreprocess, gensim_corpora as gc, classification_exceptions as e
from shorttext.utils.textpreprocessing import tokenize
import numpy as np



# abstract class
class LatentTopicModeler(ABC):
    """
    Abstract class for various topic modeler.
    """
    def __init__(self,
                 preprocessor=textpreprocess.standard_text_preprocessor_1(),
                 normalize=True):
        """ Initialize the modeler.

        :param preprocessor: function that preprocesses the text. (Default: `shorttext.utils.textpreprocess.standard_text_preprocessor_1`)
        :param normalize: whether the retrieved topic vectors are normalized. (Default: True)
        :type preprocessor: function
        :type normalize: bool
        """
        self.preprocessor = preprocessor
        self.normalize = normalize
        self.trained = False

    def generate_corpus(self, classdict):
        """ Calculate the gensim dictionary and corpus, and extract the class labels
        from the training data. Called by :func:`~train`.

        :param classdict: training data
        :return: None
        :type classdict: dict
        """
        self.dictionary, self.corpus, self.classlabels = gc.generate_gensim_corpora(classdict,

                                                                                    preprocess_and_tokenize=lambda sent: tokenize(self.preprocessor(sent)))