# Path: mlscripts/text/word_desc.py
# class WordDesc:
#     def __init__(self, id, stem):
#         self.__id = id
#         self.__stem = stem
#         self.__n_doc = 0
#         self.__n_upper = 0
#         self.__n_lower = 0
#         
#     def is_noun(self):
#         return self.__n_upper >= 1#/ (self.__n_upper + self.__n_lower) >= 0.5
#     
#     def add_variant(self, variant):
#         if variant.istitle():
#             self.__n_upper += 1
#         else:
#             self.__n_lower += 1
#     
#     @property
#     def stem(self):
#         return self.__stem
#     
#     @property
#     def total_count(self):
#         return (self.__n_upper + self.__n_lower)
#      
#     @property
#     def document_count(self):
#         return self.__n_doc
#      
#     @document_count.setter
#     def document_count(self, new_count):
#         self.__n_doc = new_count
#     
#     @property
#     def id(self):
#         return self.__id


from mlscripts.text.utilities import *
from mlscripts.text.word_desc import WordDesc
from numpy import argsort
from nltk.stem.snowball import SnowballStemmer


class WordDictSyn:
    def __init__(self):
        self.__words = {}
        self.__stemmer = SnowballStemmer("german", ignore_stopwords=False)
        self.__id_mapping = {} 
        self.__current_mapping_id = 0
    
    def analyze(self, word_list):
        cleaned_list = []
        
        for word in word_list:
            #word to lower
            word = word.lower()
            #word replace special chars
            word = remove_special_chars(word)
            #word stem
            word = self.__stemmer.stem(word)
            cleaned_list.append(word)
        sorted_indices = argsort(cleaned_list)
        #cleaned_list.sort()
        previous_word = None
        for i in sorted_indices:
            stem = cleaned_list[i]
            if stem in self.__words:
                item = self.__words[stem]
                item.add_variant(word_list[i])
                if stem != previous_word:
                    item.document_count += 1
            else:

# Path: mlscripts/text/word_desc.py
# class WordDesc:
#     def __init__(self, id, stem):
#         self.__id = id
#         self.__stem = stem
#         self.__n_doc = 0
#         self.__n_upper = 0
#         self.__n_lower = 0
#         
#     def is_noun(self):
#         return self.__n_upper >= 1#/ (self.__n_upper + self.__n_lower) >= 0.5
#     
#     def add_variant(self, variant):
#         if variant.istitle():
#             self.__n_upper += 1
#         else:
#             self.__n_lower += 1
#     
#     @property
#     def stem(self):
#         return self.__stem
#     
#     @property
#     def total_count(self):
#         return (self.__n_upper + self.__n_lower)
#      
#     @property
#     def document_count(self):
#         return self.__n_doc
#      
#     @document_count.setter
#     def document_count(self, new_count):
#         self.__n_doc = new_count
#     
#     @property
#     def id(self):
#         return self.__id


# Path: mlscripts/text/word_dict_syn.py
from mlscripts.text.utilities import *
from mlscripts.text.word_desc import WordDesc
from numpy import argsort
from nltk.stem.snowball import SnowballStemmer


class WordDictSyn:
    def __init__(self):
        self.__words = {}
        self.__stemmer = SnowballStemmer("german", ignore_stopwords=False)
        self.__id_mapping = {} 
        self.__current_mapping_id = 0
    
    def analyze(self, word_list):
        cleaned_list = []
        
        for word in word_list:
            #word to lower
            word = word.lower()
            #word replace special chars
            word = remove_special_chars(word)
            #word stem
            word = self.__stemmer.stem(word)
            cleaned_list.append(word)
        sorted_indices = argsort(cleaned_list)
        #cleaned_list.sort()
        previous_word = None
        for i in sorted_indices:
            stem = cleaned_list[i]
            if stem in self.__words:
                item = self.__words[stem]
                item.add_variant(word_list[i])
                if stem != previous_word:
                    item.document_count += 1
            else:

                item = WordDesc(stem)
