sviddo commited on
Commit
a16cc92
1 Parent(s): ad233e8

remove files from mathtext-fastapi repo

Browse files
scripts/quiz/generators.py DELETED
@@ -1,20 +0,0 @@
1
- import random
2
- from .questions import generate_question_data
3
- from .utils import get_next_difficulty, generate_start_step
4
-
5
-
6
- def start_interactive_math(difficulty=0.01, do_increase: True | False = True):
7
- next_difficulty = get_next_difficulty(difficulty, do_increase)
8
- start, step = generate_start_step(difficulty)
9
- question_data = generate_question_data(start, step, question_num=random.randint(0, 4))
10
-
11
- question = question_data['question']
12
- start = question_data['start']
13
- step = question_data['step']
14
-
15
- output = {
16
- "text": question,
17
- "difficulty": next_difficulty,
18
- "question_numbers": [start, step, start + step]
19
- }
20
- return output
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scripts/quiz/hints.py DELETED
@@ -1,15 +0,0 @@
1
- import random
2
-
3
-
4
- def generate_hint(start, step, difficulty):
5
- hints = [
6
- f"What number is greater than {start} and less than {start + 2 * step}?"
7
- ]
8
- hint = random.choice(hints)
9
-
10
- output = {
11
- "text": hint,
12
- 'difficulty': difficulty,
13
- "question_numbers": [start, step, start + step]
14
- }
15
- return output
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scripts/quiz/questions.py DELETED
@@ -1,29 +0,0 @@
1
- from .utils import convert_sequence_to_string
2
-
3
-
4
- def generate_question_data(start, step, question_num=1):
5
- """returns question by provided number with filled parameters
6
-
7
- parameters
8
- ----------
9
- :start: current number
10
- :step: interval between current and next numbers
11
- :question_num: question number"""
12
- seq = convert_sequence_to_string(start, step)
13
- start_from_num = start + 2 * step
14
- questions = [
15
- f"Let's practice counting {convert_sequence_to_string(start, step, sep='... ')} After {start_from_num}, what is the next number you will count?\n{seq}",
16
- f"What number comes {step} number after {start_from_num}?\n{seq}",
17
- f"We're counting by {step}s. What number is 1 after {start_from_num}?\n{seq}",
18
- f"What is {step} number up from {start_from_num}?\n{seq}",
19
- f"If we count up {step} from {start_from_num}, what number is next?\n{seq}",
20
- ]
21
- questions_data = []
22
- for quest in questions:
23
- questions_data.append({
24
- "question": quest,
25
- "answer": start_from_num + step,
26
- "start": start_from_num,
27
- "step": step
28
- })
29
- return questions_data[question_num]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scripts/quiz/utils.py DELETED
@@ -1,42 +0,0 @@
1
- import pandas
2
- import random
3
- from scipy.interpolate import interp1d
4
- from typing import Literal
5
-
6
- def get_next_difficulty(difficulty, do_increase: Literal[True, False] = True):
7
- if do_increase:
8
- if difficulty >= 0.95:
9
- next_difficulty = round(random.uniform(0.95, 0.99), 2)
10
- else:
11
- next_difficulty = round(random.uniform(difficulty + 0.01, difficulty + 0.05), 2)
12
- else:
13
- if difficulty <= 0.05:
14
- next_difficulty = round(random.uniform(0.01, 0.05), 2)
15
- else:
16
- next_difficulty = round(random.uniform(difficulty - 0.05, difficulty - 0.01), 2)
17
-
18
- return next_difficulty
19
-
20
-
21
- def generate_start_step(difficulty: float, path_to_csv_file: str = "scripts/quiz/data.csv"):
22
- """generate start and step values interpolating results to function built from data from file"""
23
- df = pandas.read_csv(path_to_csv_file, delimiter=',', header=0, names=['difficulty', 'start'])
24
- all_rows = df.loc[:]
25
-
26
- difficulties = [row_data['difficulty'] for _, row_data in all_rows.iterrows()]
27
- starts = [row_data['start'] for _, row_data in all_rows.iterrows()]
28
-
29
- interp_start_func = interp1d(difficulties, starts)
30
- generated_start = round(float(interp_start_func(difficulty)))
31
- if difficulty <= 0.3:
32
- step = 1
33
- elif difficulty > 0.6:
34
- step = 10
35
- else:
36
- step = 5
37
- return (generated_start, step)
38
-
39
-
40
- def convert_sequence_to_string(start, step, sep=", "):
41
- stop = start + 3 * step
42
- return sep.join([str(num) for num in range(start, stop, step)]) + sep