feat: solution for 'Экзамен: Самокорректирующийся агент'

This commit is contained in:
2026-06-30 13:14:33 +03:00
parent 7b2e405dfa
commit 7ae19c1b89
8 changed files with 328 additions and 80 deletions
+52 -27
View File
@@ -1,54 +1,79 @@
# SelfCorrecting Agent
This repository contains a minimal **Node.js** implementation of a selfcorrecting agent.
The project uses **no external frameworks** only the Node.js standard library.
A lightweight Python program that demonstrates a simple selfcorrecting agent.
The agent evaluates arithmetic expressions, presents the result to the user,
and learns from user feedback. Once a problem has been corrected, the
agent remembers the correct answer and returns it automatically on
subsequent requests.
> **Note**
> This project is intentionally minimal to illustrate the concept of a
> selfcorrecting system. It is not intended for production use.
## Features
- **Whitespace normalization** removes leading/trailing spaces and collapses multiple spaces.
- **Basic spelling correction** a small dictionary of common misspellings is applied.
- **Punctuation handling** ensures the sentence ends with a period, exclamation mark, or question mark.
## Requirements
- Node.js 14 or newer
- **Safe evaluation** of arithmetic expressions (`+`, `-`, `*`, `-`, `**`).
- **Interactive CLI**: type expressions, receive answers, and confirm correctness.
- **Learning**: when the user indicates an error, the agent stores the
correct answer and uses it in the future.
- **Persistence**: learned knowledge is saved to `knowledge.json` in the
current working directory.
## Installation
No installation is required. Just clone the repository and run the script.
The project requires Python3.8 or newer.
```bash
# Clone the repository
git clone https://git.brojs.ru/kuzakhmetovartur/ekzamen-samokorrektiruyuschiysya-agent.git
cd ekzamen-samokorrektiruyuschiysya-agent
# (Optional) Create a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\\Scripts\\activate
# Install dependencies (none required for the core functionality)
pip install -r requirements.txt # Empty file, kept for compatibility
```
## Usage
Run the script from the command line, passing the sentence you want to correct as an argument.
Run the program from the command line:
```bash
node src/index.js " This is teh example sentence wich needs correction "
python -m src.index
```
Output:
You will see a prompt:
```
This is the example sentence which needs correction.
SelfCorrecting Agent
Type 'exit' to quit.
Enter problem:
```
## Project Structure
Enter an arithmetic expression, e.g.:
```
src/
└── index.js # Main implementation
README.md # Project documentation
Enter problem: 2 + 3 * 4
````
The program will output:
````
Answer: 14
Is this correct? (y/n):
````
- **y** if the answer is correct.
- **n** and then provide the correct answer if the program made a mistake.
To exit, type **exit** or **quit**.
## Example Session
```
## Contributing
Feel free to fork the repository and submit pull requests.
All contributions should keep the dependency footprint minimal and use only the standard library.
## License
This project is licensed under the MIT License.
SelfCorrecting Agent
Type … (truncated for brevity)
```