File size: 6,472 Bytes
70c7f04
8b82e6e
 
 
 
70c7f04
 
 
 
 
 
 
 
8b82e6e
 
70c7f04
8b82e6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70c7f04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b82e6e
 
 
 
70c7f04
 
 
8b82e6e
70c7f04
 
 
 
 
8b82e6e
 
70c7f04
8b82e6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
from lib.files import *
from lib.memory import *
from lib.grapher import *
from lib.pipes import *
from lib.entropy import *
from lib.sonsofstars import *
import internetarchive

longMem = TextFinder("resources")
coreAi = AIAssistant()
memory = MemoriaRobotNLP(max_size=200000)
grapher = Grapher(memoria_nlp)
sensor_request = APIRequester()

class I:
    def __init__(self, prompt, frases_yo, preferencias, propiedades_persona):
        self.frases_yo = frases_yo
        self.preferencias = preferencias
        self.propiedades_persona = propiedades_persona
        self.dopamina = 0.0

        self.frases_yo = frases_yo
        self.preferencias = preferencias
        self.propiedades_persona = propiedades_persona
        self.dopamina = 0.0

    def obtener_paths_grafo(self, grafo_ngx):
        # Funci贸n para obtener los paths de un grafo ngx


        pass

    ## create questions from internet archive 
    def crear_preguntas(self,txt):
        search = internetarchive.search_items(sys.argv[1])
        res = []
        for result in search:
            print(result['identifier'])
            idc=result["identifier"]
            

            headers = {"accept": "application/json"}

        ## get book pages
            req2 = requests.get("https://archive.org/stream/"+idc+"/"+idc+"_djvu.txt",headers=headers)
        #print(req2.text)
            try:
                txt = req2.text.split("<pre>")[1].split("</pre>")[0].split(" <!--")[0]

                for x in txt.split("\n"):
                    if "?" in x:
                        res.append(x)

            except:
                pass

        return res


    # generate thinks and questions over prompt data, compare with ourself datasets, return matches with sentiment analysys
    def think_gen(self,txt):
        
        think_about = longMem.find_matches(txt)
        for T in thinkabout:
            ## get subject by entropy or pos tagger
            subjects = coreAi.entity_pos_tagger(txt)
            ## get NC from , filtering from gramatical tags
            subjects_low = coreAi.grammatical_pos_tagger(txt)
            ## generate questoins
            questions=[]
            ## create cuestions from internet archive books
            for sub in subjects:
                questions.append(this.crear_preguntas(txt))
            
            ## fast checks from gematria similarity
            ##questions_togem = 
            ## gematria_search =

            questions_subj=[]
            for q in questoins:
                questions_subj.append(coreAi.entity_pos_tagger(q))
            
            memoryShortTags = memory.buscar_conceptos_patron(subjects)

            ## get tags of subject
            subj_tags = coreAi.entity_pos_tagger(T)
            
            for sub in subjects: 
                memory.agregar_concepto(sub,",".(questions_subj)+",".join(memoryShortTags))
                memory.agregar_concepto(sub,T+",".join(memoryShortTags))


        ## check if something is need to add to ourself datasets
        ## make sentiment analys
        ## check if dopamine prompt is true or false over the information
        ## set weight to information depending of generated dopamine
        ## add dopamine wights to the dopamine concept dataset



    def crear_path_grafo(self,text):
        pos_tags = assistant.grammatical_pos_tagger(text)
        ner_results = coreAi.entity_pos_tagger(text)


    def crear_circuito_logico(self):
        # Funci贸n para crear un circuito l贸gico con un algoritmo espec铆fico
        pass

    def tomar_decision_sentimiento(self, sentimiento):
        
        sentiments = coreAi.sentiment_tags(sentimiento)
        # Funci贸n para tomar una decisi贸n booleana con un an谩lisis de sentimiento
        similarity = coreAi.similarity_tag(self, sentenceA,sentenceB)
        ## Check by similarity over memory tag paths


        return sentiments

    def hacer_predicciones_texto(self, texto):

        # Funci贸n para hacer predicciones de texto futuro por similitud
        pass

    def agregar_preferencia(self, preferencia):
        # Funci贸n para a帽adir una entrada al dataset de preferencias
        self.preferencias.append(preferencia)

    def agregar_frase_yo(self, frase):
        # Funci贸n para a帽adir una frase al dataset de frases de yo
        self.frases_yo.append(frase)

    def eliminar_preferencia(self, preferencia):
        # Funci贸n para eliminar una entrada del dataset de preferencias
        if preferencia in self.preferencias:
            self.preferencias.remove(preferencia)

    def eliminar_frase_yo(self, frase):
        # Funci贸n para eliminar una frase del dataset de frases de yo
        if frase in self.frases_yo:
            self.frases_yo.remove(frase)

    def generar_pregunta(self, prompt):
        # Funci贸n para generar preguntas sobre un prompt
        pregunta = prompt + " 驴Qu茅 opinas sobre esto?"
        return pregunta

    def responder_pregunta(self, pregunta):
        # Funci贸n para responder preguntas
        respuesta = "No estoy seguro de qu茅 opinar sobre eso."
        return respuesta

    def discriminar_y_agregar(self, informacion, dataset):
        # Funci贸n para discriminar y agregar informaci贸n a los datasets
        if "yo" in informacion.lower():
            self.agregar_frase_yo(informacion)
        elif "preferencia" in informacion.lower():
            self.agregar_preferencia(informacion)
        elif "propiedad" in informacion.lower():
            # Aqu铆 podr铆as agregar l贸gica para actualizar las propiedades de la persona
            pass
        else:
            # Aqu铆 podr铆as manejar otros tipos de informaci贸n
            pass


if __name__ == "__main__":

    # Ejemplo de uso:
    frases_yo = ["Yo soy inteligente", "Yo puedo lograr lo que me proponga"]
    preferencias = ["Cine", "M煤sica", "Viajar"]
    propiedades_persona = {"carisma": 0.8, "destreza": 0.6, "habilidad": 0.9}
    yo = Yo(frases_yo, preferencias, propiedades_persona)

    # Generar pregunta
    pregunta_generada = yo.generar_pregunta("Hoy es un d铆a soleado.")
    print("Pregunta generada:", pregunta_generada)

    # Responder pregunta
    respuesta = yo.responder_pregunta(pregunta_generada)
    print("Respuesta:", respuesta)

    # Discriminar y agregar informaci贸n
    informacion = "Me gusta ir al cine."
    yo.discriminar_y_agregar(informacion, yo.preferencias)
    print("Preferencias actualizadas:", yo.preferencias)