Primera fase lista: Output CSV
This commit is contained in:
168
action_flow/fase1_extract.ipynb
Normal file
168
action_flow/fase1_extract.ipynb
Normal file
@@ -0,0 +1,168 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "0106c35d-8bd3-46e5-ae63-8bdcc7f3c57e",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Imports"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"id": "07f1b7f9-e990-4f49-81ec-5e7b85533ce6",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import os \n",
|
||||
"import sys"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"id": "2c0608fc-aaf0-4050-9802-132a3f57e264",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"module_path = os.path.abspath(os.path.join('..'))\n",
|
||||
"\n",
|
||||
"# Add to sys.path if not already present\n",
|
||||
"if module_path not in sys.path:\n",
|
||||
" sys.path.append(module_path)\n",
|
||||
" print(module_path)\n",
|
||||
"\n",
|
||||
"from extraccion import agentes_entidades"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e9945d03-5f4d-46f4-bf05-9effca5fbc30",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Variables"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"id": "d9af271a-03f9-41c7-acf9-7497c5463cc8",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"INPUT_FOLDER = f\"{module_path}/input/Preguntas Categoricas/\"\n",
|
||||
"OUTPUT_FOLDER = f\"{module_path}/output/fase1\"\n",
|
||||
"FILES_TO_PROCESS = os.listdir(INPUT_FOLDER)\n",
|
||||
"DELIMITER = \"|^\"\n",
|
||||
"DIC_QUESTIONS = {\n",
|
||||
" \"Encuesta_MediaG01Q02.csv\":agentes_entidades.extractor_pre_1\n",
|
||||
" # COMPLETAR RESTO\n",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "eb564083-f884-4bb4-8e4b-191d3bbd887e",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Functions"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 32,
|
||||
"id": "ec64ee5e-1d45-4d1e-805c-45a608eea33a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def extract_answers(answers):\n",
|
||||
" answer_formated = \"\"\n",
|
||||
" iterator_answers = answers.acciones\n",
|
||||
" for item in iterator_answers:\n",
|
||||
" answer_formated+=f\"{item.accion}{DELIMITER}\"\n",
|
||||
" return answer_formated"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 33,
|
||||
"id": "886d7f02-0f5a-4a1f-8bd2-cb18c0a86360",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def format_answer(dataframe,function):\n",
|
||||
" dataframe[\"respuestas_formato\"] = None\n",
|
||||
" for index, row in dataframe.iterrows():\n",
|
||||
" answers = function (row['respuesta'])\n",
|
||||
" answer_to_insert = extract_answers(answers)\n",
|
||||
" dataframe.loc[index,'respuestas_formato'] = answer_to_insert"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"id": "16d3fb54-7385-401e-8a0a-b594d08ae181",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def format_all_answers(Dic_questions):\n",
|
||||
" for key,value in Dic_questions.items():\n",
|
||||
" question_dataframe = pd.read_csv(INPUT_FOLDER+\"/\"+key)\n",
|
||||
" format_answer(question_dataframe, value)\n",
|
||||
" question_dataframe.to_csv(OUTPUT_FOLDER+\"/\"+key)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 35,
|
||||
"id": "93c06255-a231-4aee-899d-803d9fb0b342",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"----------------------------------------------------------------------------------------------------\n",
|
||||
"Realiza promoción por radio para informar a la comunidad sobre el acceso a educación media.\n",
|
||||
"----------------------------------------------------------------------------------------------------\n",
|
||||
"----------------------------------------------------------------------------------------------------\n",
|
||||
"Difunde mensajes informativos en la portería del establecimiento educativo.\n",
|
||||
"----------------------------------------------------------------------------------------------------\n",
|
||||
"----------------------------------------------------------------------------------------------------\n",
|
||||
"Utiliza carteleras del plantel para comunicar información sobre acceso a educación media.\n",
|
||||
"----------------------------------------------------------------------------------------------------\n",
|
||||
"----------------------------------------------------------------------------------------------------\n",
|
||||
"Implementa estrategia de comunicación de voz a voz con la comunidad educativa para promover el acceso a educación media.\n",
|
||||
"----------------------------------------------------------------------------------------------------\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"format_all_answers(DIC_QUESTIONS)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.13.7"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
80
action_flow/fase1_extract.py
Normal file
80
action_flow/fase1_extract.py
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
# # Imports
|
||||
|
||||
# In[29]:
|
||||
|
||||
|
||||
import pandas as pd
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
# In[30]:
|
||||
|
||||
|
||||
module_path = os.path.abspath(os.path.join('..'))
|
||||
|
||||
# Add to sys.path if not already present
|
||||
if module_path not in sys.path:
|
||||
sys.path.append(module_path)
|
||||
print(module_path)
|
||||
|
||||
from extraccion import agentes_entidades
|
||||
|
||||
|
||||
# # Variables
|
||||
|
||||
# In[31]:
|
||||
|
||||
|
||||
INPUT_FOLDER = f"{module_path}/input/Preguntas Categoricas/"
|
||||
OUTPUT_FOLDER = f"{module_path}/output/fase1"
|
||||
FILES_TO_PROCESS = os.listdir(INPUT_FOLDER)
|
||||
DELIMITER = "|^"
|
||||
DIC_QUESTIONS = {
|
||||
"Encuesta_MediaG01Q02.csv":agentes_entidades.extractor_pre_1
|
||||
# COMPLETAR RESTO
|
||||
}
|
||||
|
||||
|
||||
# # Functions
|
||||
|
||||
# In[32]:
|
||||
|
||||
|
||||
def extract_answers(answers):
|
||||
answer_formated = ""
|
||||
iterator_answers = answers.acciones
|
||||
for item in iterator_answers:
|
||||
answer_formated+=f"{item.accion}{DELIMITER}"
|
||||
return answer_formated
|
||||
|
||||
|
||||
# In[33]:
|
||||
|
||||
|
||||
def format_answer(dataframe,function):
|
||||
dataframe["respuestas_formato"] = None
|
||||
for index, row in dataframe.iterrows():
|
||||
answers = function (row['respuesta'])
|
||||
answer_to_insert = extract_answers(answers)
|
||||
dataframe.loc[index,'respuestas_formato'] = answer_to_insert
|
||||
|
||||
|
||||
# In[34]:
|
||||
|
||||
|
||||
def format_all_answers(Dic_questions):
|
||||
for key,value in Dic_questions.items():
|
||||
question_dataframe = pd.read_csv(INPUT_FOLDER+"/"+key)
|
||||
format_answer(question_dataframe, value)
|
||||
question_dataframe.to_csv(OUTPUT_FOLDER+"/"+key)
|
||||
|
||||
|
||||
# In[35]:
|
||||
|
||||
|
||||
format_all_answers(DIC_QUESTIONS)
|
||||
|
||||
0
extraccion/__init__.py
Normal file
0
extraccion/__init__.py
Normal file
@@ -15,6 +15,7 @@ from extraccion.schemas_entidades import (
|
||||
Expectativas,
|
||||
)
|
||||
import yaml
|
||||
import os
|
||||
|
||||
|
||||
# Cargar la configración de prompts desde el archivo .yaml
|
||||
@@ -24,7 +25,7 @@ def load_prompts_config(file_path):
|
||||
return prompts_config
|
||||
|
||||
|
||||
path_prompts = "extraccion/prompts.yaml"
|
||||
path_prompts = f"{os.path.abspath(os.path.join('..'))}/extraccion/prompts.yaml"
|
||||
prompts_config = load_prompts_config(path_prompts)
|
||||
|
||||
context = LLMContext()
|
||||
|
||||
2
input/Preguntas Categoricas/Encuesta_MediaG01Q02.csv
Normal file
2
input/Preguntas Categoricas/Encuesta_MediaG01Q02.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
cod_dane,cod_pregunta,respuesta
|
||||
205120000366/I.E. AURELIO MEJIA,G01Q02,"Realiza promoción por radio, mensajes informativos en porteria y carteleras del plantel, voz a voz con la comunidad educativa"
|
||||
|
2
input/Preguntas Categoricas/Encuesta_MediaG01Q04.csv
Normal file
2
input/Preguntas Categoricas/Encuesta_MediaG01Q04.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
cod_dane,cod_pregunta,respuesta
|
||||
205120000366/I.E. AURELIO MEJIA,G01Q04,Continuamente hacer encuestas de satisfacción para conocer las inquietudes y deseos que tienen nuestros estudiantes. También se ofrecen talleres de nivelación para aquellos que presentan dificultades en el rendimiento
|
||||
|
2
input/Preguntas Categoricas/Encuesta_MediaG01Q10.csv
Normal file
2
input/Preguntas Categoricas/Encuesta_MediaG01Q10.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
cod_dane,cod_pregunta,respuesta
|
||||
205120000366/I.E. AURELIO MEJIA,G01Q10,"Desde hace ya mas de tres años no se actualizaba el PEI, se incluyó el tema de los ajustes razonables y se reorganizó los principios instritucionales"
|
||||
|
2
input/Preguntas Categoricas/Encuesta_MediaG03Q17.csv
Normal file
2
input/Preguntas Categoricas/Encuesta_MediaG03Q17.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
cod_dane,cod_pregunta,respuesta
|
||||
205120000366/I.E. AURELIO MEJIA,G03Q17,"PIAR, STEAM,+H y tecnologías"
|
||||
|
2
input/Preguntas Categoricas/Encuesta_MediaG03Q18.csv
Normal file
2
input/Preguntas Categoricas/Encuesta_MediaG03Q18.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
cod_dane,cod_pregunta,respuesta
|
||||
205120000366/I.E. AURELIO MEJIA,G03Q18,Generalmente la encuesta en linea
|
||||
|
2
input/Preguntas Categoricas/Encuesta_MediaG03Q19.csv
Normal file
2
input/Preguntas Categoricas/Encuesta_MediaG03Q19.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
cod_dane,cod_pregunta,respuesta
|
||||
205120000366/I.E. AURELIO MEJIA,G03Q19,No
|
||||
|
2
input/Preguntas Categoricas/Encuesta_MediaG04Q22.csv
Normal file
2
input/Preguntas Categoricas/Encuesta_MediaG04Q22.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
cod_dane,cod_pregunta,respuesta
|
||||
205120001435/I.E. GASPAR DE RODAS,G04Q22,l la participación de los padres de familia y los estudiantes por lo tanto como estrategia principal esta que ellos participen dando la información de que hay cupos para educación media creando material informativo y que sean los encargados de la distribución en sus barrios
|
||||
|
3
input/Preguntas Categoricas/Encuesta_MediaG04Q23.csv
Normal file
3
input/Preguntas Categoricas/Encuesta_MediaG04Q23.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
cod_dane,cod_pregunta,respuesta
|
||||
205120001435/I.E. GASPAR DE RODAS,G04Q23,"A nivel social y económico, el comercio en la zona necesita mano de obra barata y los estudiantes prefieren ir a trabajar asi sea por poco dinero pero tener algo con que sobrevivir.
|
||||
A nivel cultural en las familias son pocos los bachilleres que hay entonces terminar no es motivación"
|
||||
|
2
input/Preguntas Categoricas/Encuesta_MediaG04Q25.csv
Normal file
2
input/Preguntas Categoricas/Encuesta_MediaG04Q25.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
cod_dane,cod_pregunta,respuesta
|
||||
205120001435/I.E. GASPAR DE RODAS,G04Q25,
|
||||
|
2
input/Preguntas Categoricas/Encuesta_MediaG05Q30.csv
Normal file
2
input/Preguntas Categoricas/Encuesta_MediaG05Q30.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
cod_dane,cod_pregunta,respuesta
|
||||
205120001435/I.E. GASPAR DE RODAS,G05Q30,"La empatía, trabajo en equipo y se trabaja de manera muy fuerte las competencias matemáticas"
|
||||
|
2
input/Preguntas Categoricas/Encuesta_MediaG05Q34.csv
Normal file
2
input/Preguntas Categoricas/Encuesta_MediaG05Q34.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
cod_dane,cod_pregunta,respuesta
|
||||
205120001435/I.E. GASPAR DE RODAS,G05Q34,Rubricas de evaluación por áreas de conocimiento y listas de chequeo de acuerdo a las dimensiones del desarrollo con el grado de transición
|
||||
|
2
output/fase1/Encuesta_MediaG01Q02.csv
Normal file
2
output/fase1/Encuesta_MediaG01Q02.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
,cod_dane,cod_pregunta,respuesta,respuestas_formato
|
||||
0,205120000366/I.E. AURELIO MEJIA,G01Q02,"Realiza promoción por radio, mensajes informativos en porteria y carteleras del plantel, voz a voz con la comunidad educativa",Realiza promoción por radio para informar a la comunidad sobre el acceso a educación media.|^Difunde mensajes informativos en la portería del establecimiento educativo.|^Utiliza carteleras del plantel para comunicar información sobre acceso a educación media.|^Implementa estrategia de comunicación de voz a voz con la comunidad educativa para promover el acceso a educación media.|^
|
||||
|
@@ -15,3 +15,4 @@ llm = context.get_llm()
|
||||
pregunta = "¿Cuál es el mejor modelo de lenguaje?"
|
||||
respuesta = llm.invoke(pregunta)
|
||||
print(respuesta)
|
||||
|
||||
Reference in New Issue
Block a user