Extract and regenerate math exercises using AI and Python
Budget: $250 – $750 USD
I have 3 markdown files full of math exercises in French and folder with their answer keys. I would to process them to generate new math exercises with answer key. To do so, we can use a chatbot API like the one from chatgpt.
First we need to extract each exercise with its number. For example the first exercise is :
Number: "NO2"
Exercise: "Si je pense à un nombre, je lui retranche (-12) et je trouve 3. Quel est ce nombre?"
Here is the exercise is not well written, so we can use an AI API to rewrite it:
Number: "NO2"
Exercise: "Si en pensant à un nombre, en lui retranchant (-12), on trouve 3, quel est ce nombre ?"
Often there is unnecessary content between the exercises that needs to be removed.
Each exercise with its number has to be stored in a Python huge list.
Then we need to extract the answer of each exercise which is inside the math_answer_key.zip file. The answer has to be added to the Python list. For example:
Number: "NO2"
Exercise: "Si en pensant à un nombre, en lui retranchant (-12), on trouve 3, quel est ce nombre ?"
Answer: "-9"
If the answer is not available, we use a chatbot API to generate an answer.
Then we ask the chatbot API to generate a detailed correction BASED ON ITS ANSWER.
Number: "NO2"
Exercise: "Si en pensant à un nombre, en lui retranchant (-12), on trouve 3, quel est ce nombre ?"
Answer: "-9"
Correction: """## Étape 1 : Analyse de l'énoncé
Retrancher (-12) revient à **ajouter 12** (car retrancher un nombre négatif équivaut à effectuer une addition).
---
## Étape 2 : Traduction en équation
Soit \( x \) le nombre cherché.
L'énoncé donne l'équation suivante :
\[
x + 12 = 3
\]
---
## Étape 3 : Résolution de l'équation
Pour isoler \( x \), on soustrait 12 des deux côtés de l'équation :
\[
x + 12 - 12 = 3 - 12
\]
\[
x = -9
\]
---
## Étape 4 : Vérification
Si on prend \( x = -9 \) :
- En lui ajoutant 12 :
\[
-9 + 12 = 3
\]
Cela correspond bien à l'énoncé.
---
## Conclusion
Le nombre cherché est **\(-9\)**."""
Then we use AI to determine the category of the exercise. For example:
Number: "NO2"
Exercise: "Si en pensant à un nombre, en lui retranchant (-12), on trouve 3, quel est ce nombre ?"
Answer: "-9"
Category: "Équations"
Then we generate a new exercise with a new correction based on the initial exercise and its correction.
Number: "NO2"
Exercise: "Si en pensant à un nombre, en lui retranchant (-12), on trouve 3, quel est ce nombre ?"
Answer: "-9"
Exercise2: "En pensant à un nombre, si je lui ajoute (-8), je trouve 15. Quel est ce nombre ?"
Answer2: "23"
Category: "Équations"
Then we make several markdown documents for each category. Each document should contain all the exercises of one category without the answer and without the correction. The exercises should be sorted by size of correction with a new number.
We also generate a page for each exercise with the correction.
Then the pages should be converted in HTML.
First we need to extract each exercise with its number. For example the first exercise is :
Number: "NO2"
Exercise: "Si je pense à un nombre, je lui retranche (-12) et je trouve 3. Quel est ce nombre?"
Here is the exercise is not well written, so we can use an AI API to rewrite it:
Number: "NO2"
Exercise: "Si en pensant à un nombre, en lui retranchant (-12), on trouve 3, quel est ce nombre ?"
Often there is unnecessary content between the exercises that needs to be removed.
Each exercise with its number has to be stored in a Python huge list.
Then we need to extract the answer of each exercise which is inside the math_answer_key.zip file. The answer has to be added to the Python list. For example:
Number: "NO2"
Exercise: "Si en pensant à un nombre, en lui retranchant (-12), on trouve 3, quel est ce nombre ?"
Answer: "-9"
If the answer is not available, we use a chatbot API to generate an answer.
Then we ask the chatbot API to generate a detailed correction BASED ON ITS ANSWER.
Number: "NO2"
Exercise: "Si en pensant à un nombre, en lui retranchant (-12), on trouve 3, quel est ce nombre ?"
Answer: "-9"
Correction: """## Étape 1 : Analyse de l'énoncé
Retrancher (-12) revient à **ajouter 12** (car retrancher un nombre négatif équivaut à effectuer une addition).
---
## Étape 2 : Traduction en équation
Soit \( x \) le nombre cherché.
L'énoncé donne l'équation suivante :
\[
x + 12 = 3
\]
---
## Étape 3 : Résolution de l'équation
Pour isoler \( x \), on soustrait 12 des deux côtés de l'équation :
\[
x + 12 - 12 = 3 - 12
\]
\[
x = -9
\]
---
## Étape 4 : Vérification
Si on prend \( x = -9 \) :
- En lui ajoutant 12 :
\[
-9 + 12 = 3
\]
Cela correspond bien à l'énoncé.
---
## Conclusion
Le nombre cherché est **\(-9\)**."""
Then we use AI to determine the category of the exercise. For example:
Number: "NO2"
Exercise: "Si en pensant à un nombre, en lui retranchant (-12), on trouve 3, quel est ce nombre ?"
Answer: "-9"
Category: "Équations"
Then we generate a new exercise with a new correction based on the initial exercise and its correction.
Number: "NO2"
Exercise: "Si en pensant à un nombre, en lui retranchant (-12), on trouve 3, quel est ce nombre ?"
Answer: "-9"
Exercise2: "En pensant à un nombre, si je lui ajoute (-8), je trouve 15. Quel est ce nombre ?"
Answer2: "23"
Category: "Équations"
Then we make several markdown documents for each category. Each document should contain all the exercises of one category without the answer and without the correction. The exercises should be sorted by size of correction with a new number.
We also generate a page for each exercise with the correction.
Then the pages should be converted in HTML.