This repository contains the code and data used for the TFM project focused on lexical simplification, dictionary generation, definition extraction, evaluation, and model benchmarking.
The project combines several components:
application/ — web application, backend API, and frontend interface.detection_module/ — detection and preprocessing logic.generation_module/ — definition generation and model usage workflows.dictionary_programs/ — dictionary extraction, normalization, and analysis utilities.metrics_module/ — evaluation, readability, and metric computation.data/ — benchmark datasets, extracted definitions, and dictionaries.tests/ — validation and regression tests.The project depends on Python packages listed in requirements.txt.
Recommended setup:
cd TFM
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
application/backend/ — backend services and API entry points.application/frontend/ — Angular frontend.detection_module/ — detection of botrrowings in a given text.generation_module/ — generation of definitions using different models.metrics_module/ — metric computation and experimental analysis.dictionary_programs/ — programs used to generate all the data.data/dictionaries/ — all the versions of the dictionaries generated.data/test_datasets/ — all the versions of the test datasets generated.The generation_module/use_models.py script generates simplified definitions for terms using multiple language models.
Available Models:
Usage:
cd generation_module
python use_models.py
The script:
../data/dictionaries/transformed_terms.json{field: {id_term, term, original, adapted, context, simplified}}experiments/results_v1/, experiments/results_v2/, etc.)Configuration:
prompt_templates list in the main() function to customize the prompt.input_file to point to your dataset.llama.json, ministral.json).Output Structure: Each model generates a JSON file containing:
{
"field_name": {
"id_term": "...",
"term": "...",
"original": "...",
"adapted": "...",
"context": "...",
"simplified": "Generated definition here"
}
}
The metrics_module/hulat_metrics.py script evaluates the quality of generated definitions using multiple linguistic and readability metrics.
Supported Metrics:
Usage:
cd metrics_module
python hulat_metrics.py --lang es --input_folder /path/to/models/results --out /path/to/output
Parameters:
--lang — Language for evaluation: es (Spanish) or en (English) [required]--input_folder — Path to folder containing model JSON files, where filename = model name [required]--out — Path to output folder for results (JSON, CSV, and CodeCarbon emissions reports) [required]Input Format:
The script expects JSON files in input_folder with the following structure:
{
"field_name": {
"original": "original text",
"simplified": "simplified definition",
"reference": "reference definition"
}
}
Outputs:
metrics_{model}.json — Full metric results per modelmetrics_{model}.csv — Metric results in tabular formatemissions_metricas_{model}.csv — Carbon emissions trackingExample:
python hulat_metrics.py --lang es --input_folder ../generation_module/experiments/results_v1 --out ./experiments/results_v1
This will:
experiments/results_v1/ (e.g., llama.json, ministral.json, etc.)experiments/results_v1/alternatively, one can use the execute_metrics.sh script to automatically compute all the metrics, using:
./execute_metrics.sh
The EASIER application provides a web-based interface for lexical simplification and borrowing detection in Spanish texts. It consists of a backend API and an Angular frontend.
Prerequisites:
Installation:
cd application/backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Configuration:
Create a .env file in application/backend/:
HUGGINGFACE_TOKEN=your_hf_token_here
Running the Backend:
cd application/backend
./restart_container.sh
The API server will start on http://localhost:5000.
Prerequisites:
Installation:
cd application/frontend
npm install
Start the backend:
cd application/backend
./restart_container.sh
Start the frontend:
cd application/frontend
ng serve
Access the application:
http://localhost:4200 in your browserdata/.This Bachelor's Thesis was developed within the framework of the research project: PID2023-148577OB-C21 Human-Centered AI: User-Driven Adapted Language Models (HUMAN_AI) Funded by: MICIU- AEI (10.13039/501100011033) - FEDER/European Union
This repository contains the code and data used for the TFM project focused on lexical simplification, dictionary generation, definition extraction, evaluation, and model benchmarking.
The project combines several components:
application/ — web application, backend API, and frontend interface.detection_module/ — detection and preprocessing logic.generation_module/ — definition generation and model usage workflows.dictionary_programs/ — dictionary extraction, normalization, and analysis utilities.metrics_module/ — evaluation, readability, and metric computation.data/ — benchmark datasets, extracted definitions, and dictionaries.tests/ — validation and regression tests.The project depends on Python packages listed in requirements.txt.
Recommended setup:
cd TFM
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
application/backend/ — backend services and API entry points.application/frontend/ — Angular frontend.detection_module/ — detection of botrrowings in a given text.generation_module/ — generation of definitions using different models.metrics_module/ — metric computation and experimental analysis.dictionary_programs/ — programs used to generate all the data.data/dictionaries/ — all the versions of the dictionaries generated.data/test_datasets/ — all the versions of the test datasets generated.The generation_module/use_models.py script generates simplified definitions for terms using multiple language models.
Available Models:
Usage:
cd generation_module
python use_models.py
The script:
../data/dictionaries/transformed_terms.json{field: {id_term, term, original, adapted, context, simplified}}experiments/results_v1/, experiments/results_v2/, etc.)Configuration:
prompt_templates list in the main() function to customize the prompt.input_file to point to your dataset.llama.json, ministral.json).Output Structure: Each model generates a JSON file containing:
{
"field_name": {
"id_term": "...",
"term": "...",
"original": "...",
"adapted": "...",
"context": "...",
"simplified": "Generated definition here"
}
}
The metrics_module/hulat_metrics.py script evaluates the quality of generated definitions using multiple linguistic and readability metrics.
Supported Metrics:
Usage:
cd metrics_module
python hulat_metrics.py --lang es --input_folder /path/to/models/results --out /path/to/output
Parameters:
--lang — Language for evaluation: es (Spanish) or en (English) [required]--input_folder — Path to folder containing model JSON files, where filename = model name [required]--out — Path to output folder for results (JSON, CSV, and CodeCarbon emissions reports) [required]Input Format:
The script expects JSON files in input_folder with the following structure:
{
"field_name": {
"original": "original text",
"simplified": "simplified definition",
"reference": "reference definition"
}
}
Outputs:
metrics_{model}.json — Full metric results per modelmetrics_{model}.csv — Metric results in tabular formatemissions_metricas_{model}.csv — Carbon emissions trackingExample:
python hulat_metrics.py --lang es --input_folder ../generation_module/experiments/results_v1 --out ./experiments/results_v1
This will:
experiments/results_v1/ (e.g., llama.json, ministral.json, etc.)experiments/results_v1/alternatively, one can use the execute_metrics.sh script to automatically compute all the metrics, using:
./execute_metrics.sh
The EASIER application provides a web-based interface for lexical simplification and borrowing detection in Spanish texts. It consists of a backend API and an Angular frontend.
Prerequisites:
Installation:
cd application/backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Configuration:
Create a .env file in application/backend/:
HUGGINGFACE_TOKEN=your_hf_token_here
Running the Backend:
cd application/backend
./restart_container.sh
The API server will start on http://localhost:5000.
Prerequisites:
Installation:
cd application/frontend
npm install
Start the backend:
cd application/backend
./restart_container.sh
Start the frontend:
cd application/frontend
ng serve
Access the application:
http://localhost:4200 in your browserdata/.This Bachelor's Thesis was developed within the framework of the research project: PID2023-148577OB-C21 Human-Centered AI: User-Driven Adapted Language Models (HUMAN_AI) Funded by: MICIU- AEI (10.13039/501100011033) - FEDER/European Union