From 960c4188488a4dae6b3bea719af76d8e5e83b88c Mon Sep 17 00:00:00 2001 From: Aldarien Date: Thu, 9 Dec 2021 21:14:28 -0300 Subject: [PATCH] Python --- python/src/ai/network.py | 1 - python/src/ai/phrase.py | 102 ------------------ python/src/ai/word.py | 84 --------------- .../__pycache__/log.cpython-39.pyc | Bin 758 -> 0 bytes 4 files changed, 187 deletions(-) delete mode 100644 python/src/ai/phrase.py delete mode 100644 python/src/ai/word.py delete mode 100644 python/src/contabilidad/__pycache__/log.cpython-39.pyc diff --git a/python/src/ai/network.py b/python/src/ai/network.py index 10d2d31..928ecac 100644 --- a/python/src/ai/network.py +++ b/python/src/ai/network.py @@ -108,7 +108,6 @@ class AI: os.remove(temp) word_list = th.split_words(obj) fits = encoder.fit_transform(word_list) - print(fits) phrases = [] for length in range(1, len(word_list) + 1): for start in range(0, len(word_list)): diff --git a/python/src/ai/phrase.py b/python/src/ai/phrase.py deleted file mode 100644 index a80a325..0000000 --- a/python/src/ai/phrase.py +++ /dev/null @@ -1,102 +0,0 @@ -import json -from src.ai.word import Word, WordType - - -class PhraseType: - TEXT = 0 - TITLE = 1 - HEADER = 2 - MOVEMENT = 3 - INVALID = 99 - - def __init__(self): - self.__id = 0 - self.__description = 'text' - - def get_id(self): - return self.__id - - def get_desc(self): - return self.__description - - def to_json(self): - return self.__id - - def load(self, phrase_id: int): - self.__id = phrase_id - if phrase_id == self.TITLE: - self.__description = 'title' - elif phrase_id == self.HEADER: - self.__description = 'header' - elif phrase_id == self.MOVEMENT: - self.__description = 'movement' - elif phrase_id == self.INVALID: - self.__description = 'invalid' - return self - - -def phrase_factory(phrase: list, phrase_type: int = None, frec: int = 1): - pt = PhraseType() - if phrase_type is not None: - pt.load(phrase_type) - ph = Phrase() - ph.set_phrase(phrase).set_type(pt).add_frec(frec - 1) - return ph - - -class Phrase: - def __init__(self): - self.__phrase = None - self.__type = None - self.__frec = 1 - - def to_json(self): - return { - 'phrase': [w.to_json() for w in self.__phrase], - 'type': self.__type.to_json(), - 'frec': self.__frec - } - - def set_phrase(self, phrase: list): - [self.add_word(w) for w in phrase] - return self - - def get_phrase(self): - return self.__phrase - - def set_type(self, phrase_type: PhraseType): - self.__type = phrase_type - return self - - def get_type(self): - return self.__type - - def add_word(self, word: Word, pos: int = None): - if self.__phrase is None: - self.__phrase = [] - if pos is None: - self.__phrase.append(word) - return self - self.__phrase = self.__phrase[:pos] + [word] + self.__phrase[pos:] - return self - - def add_frec(self, amount: int = 1): - self.__frec += amount - - def match(self, words: list): - if len(words) != len(self.__phrase): - return False - for w in self.__phrase: - if w not in words: - return False - return True - - def __repr__(self): - print(self.__phrase) - return json.dumps({ - 'phrase': [w.to_json() for w in self.get_phrase()], - 'type': self.get_type().get_desc() - }) - - def __len__(self): - return len(self.__phrase) diff --git a/python/src/ai/word.py b/python/src/ai/word.py deleted file mode 100644 index 274670a..0000000 --- a/python/src/ai/word.py +++ /dev/null @@ -1,84 +0,0 @@ -import json - - -class WordType: - STRING = 0 - NUMERIC = 1 - CURRENCY = 2 - DATE = 3 - - def __init__(self): - self.__id = 0 - self.__description = 'string' - - def to_json(self): - return self.__id - - def load(self, word_id: int): - self.__id = word_id - if word_id == self.NUMERIC: - self.__description = 'numeric' - elif word_id == self.CURRENCY: - self.__description = 'currency' - elif word_id == self.DATE: - self.__description = 'data' - return self - - def get_id(self): - return self.__id - - def get_desc(self): - return self.__description - - def __repr__(self): - return { - 'id': self.get_id(), - 'description': self.get_desc() - } - - -def word_factory(word: str, word_type: int = None, frec: int = 1): - wt = WordType() - if word_type is not None: - wt.load(word_type) - w = Word() - w.set_word(word).set_type(wt).add_frec(frec - 1) - return w - - -class Word: - def __init__(self): - self.__word = None - self.__type = None - self.__frec = 1 - - def to_json(self): - return { - 'word': self.__word, - 'type': self.__type.to_json(), - 'frec': self.__frec - } - - def set_word(self, word: str): - self.__word = word - return self - - def get_word(self): - return self.__word - - def set_type(self, word_type: WordType): - self.__type = word_type - return self - - def get_type(self): - return self.__type - - def add_frec(self, amount: int = 1): - self.__frec += amount - return self - - def __repr__(self): - return json.dumps({ - 'word': self.get_word(), - 'type': self.get_type().get_desc() - }) diff --git a/python/src/contabilidad/__pycache__/log.cpython-39.pyc b/python/src/contabilidad/__pycache__/log.cpython-39.pyc deleted file mode 100644 index 36d64f1f2c4da416fd3cdd2a4b97b8f45513b3fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 758 zcmY*X!EVz)5S?AGW4EMLkq}WO4!QV{Lz-}n5TekKRtkiak#Uy4JcoKF2hd*;G5oTih-LaxUwb! z2To$}fKzTn#3LQxjGNcM%@y^ipzn+k;U#We6OVCn3N`yXeg&?wM^P-2a3bdWjaeug zaXM~HukyEP(hyRn@&E%veRWgtIYsFQ=m_u#2aj^%8JuEz!!tSaO5DUUCAHPK%UJv6Aoy?@#>I(b zSW%i9N*XMLFCgz|U&D`=M=k#>6EgD;V;;&#B>o_k@3Uz*6#h8M{i#f66MvW{dH5!Z zBOY?U=-1EW@c%frelWd~n&>TDnT=o*w$^oYNHOwP^vm>(XSlL+gdAtG4@;Vp1?6-_ zKR1`g!nmQiaf2k?63!~HAQhYuTByJ+Auzy6GSrnpAlZ8e*>MxdS}zbeXi8nF%PJDi z@4a#^>dvI@@Tzm%a$dBY)7RCxQLR_!v{kK{%EA`LQ8HF6or*-6A7zva#qww(l%3^r zq`ewb)idzyP7HYpQ%AHA9>@1l{r8Z=$SnDo&` ZiuI7zdF)5UbRX*