diff --git a/solver-bot/src/main/python/languages.json b/solver-bot/src/main/python/languages.json index 18d611b..4a15b06 100644 --- a/solver-bot/src/main/python/languages.json +++ b/solver-bot/src/main/python/languages.json @@ -54,11 +54,13 @@ "error_displaying_application": "Error displaying task details.", "cancel": "Actions canceled.", - "method_euler": "Euler's Method", - "method_midpoint": "Midpoint Method", - "method_heun": "Heun's Method", - "method_runge_kutta": "Runge-Kutta Method", - "method_dormand_prince": "Dormand-Prince Method", + "numerical_methods": { + "euler": "Euler's Method", + "midpoint": "Midpoint Method", + "heun": "Heun's Method", + "runge_kutta": "Runge-Kutta Method", + "dormand_prince": "Dormand-Prince Method" + }, "method": "Method", "equation": "Equation", @@ -123,11 +125,13 @@ "error_displaying_application": "Ошибка при отображении деталей задачи.", "cancel": "Действия отменены.", - "method_euler": "Метод Эйлера", - "method_midpoint": "Метод Средней Точки", - "method_heun": "Метод Хойна", - "method_runge_kutta": "Метод Рунге-Кутта", - "method_dormand_prince": "Метод Дормана-Принса", + "numerical_methods": { + "euler": "Метод Эйлера", + "midpoint": "Метод Средней Точки", + "heun": "Метод Хойна", + "runge_kutta": "Метод Рунге-Кутта", + "dormand_prince": "Метод Дормана-Принса" + }, "method": "Метод", "equation": "Уравнение", @@ -192,11 +196,13 @@ "error_displaying_application": "显示任务详情时出错。", "cancel": "操作已取消。", - "method_euler": "欧拉法", - "method_midpoint": "中点法", - "method_heun": "休恩法", - "method_runge_kutta": "龙格-库塔法", - "method_dormand_prince": "多曼德-普林斯法", + "numerical_methods": { + "euler": "欧拉法", + "midpoint": "中点法", + "heun": "休恩法", + "runge_kutta": "龙格-库塔法", + "dormand_prince": "多曼德-普林斯法" + }, "method": "方法", "equation": "方程", diff --git a/solver-bot/src/main/python/shell.py b/solver-bot/src/main/python/shell.py index ab2811b..93c8c9e 100644 --- a/solver-bot/src/main/python/shell.py +++ b/solver-bot/src/main/python/shell.py @@ -44,7 +44,7 @@ MENU, EQUATION, INITIAL_X, INITIAL_Y, REACH_POINT, STEP_SIZE = range(6) -DEFAULT_METHOD = "method_runge_kutta" +DEFAULT_METHOD = "runge_kutta" DEFAULT_ROUNDING = "4" DEFAULT_LANGUAGE = "en" DEFAULT_HINTS = "true" @@ -203,35 +203,35 @@ async def settings_method(update: Update, context: ContextTypes.DEFAULT_TYPE): keyboard = [ [InlineKeyboardButton( - f"→ {LANG_TEXTS[current_language]["method_euler"]} ←", - callback_data="method_euler") - if current_method == "method_euler" else InlineKeyboardButton( - LANG_TEXTS[current_language]["method_euler"], - callback_data="method_euler")], + f"→ {LANG_TEXTS[current_language]["numerical_methods"]["euler"]} ←", + callback_data="euler") + if current_method == "euler" else InlineKeyboardButton( + LANG_TEXTS[current_language]["numerical_methods"]["euler"], + callback_data="euler")], [InlineKeyboardButton( - f"→ {LANG_TEXTS[current_language]["method_midpoint"]} ←", - callback_data="method_midpoint") - if current_method == "method_midpoint" else InlineKeyboardButton( - LANG_TEXTS[current_language]["method_midpoint"], - callback_data="method_midpoint")], + f"→ {LANG_TEXTS[current_language]["numerical_methods"]["midpoint"]} ←", + callback_data="midpoint") + if current_method == "midpoint" else InlineKeyboardButton( + LANG_TEXTS[current_language]["numerical_methods"]["midpoint"], + callback_data="midpoint")], [InlineKeyboardButton( - f"→ {LANG_TEXTS[current_language]["method_heun"]} ←", - callback_data="method_heun") - if current_method == "method_heun" else InlineKeyboardButton( - LANG_TEXTS[current_language]["method_heun"], - callback_data="method_heun")], + f"→ {LANG_TEXTS[current_language]["numerical_methods"]["heun"]} ←", + callback_data="heun") + if current_method == "heun" else InlineKeyboardButton( + LANG_TEXTS[current_language]["numerical_methods"]["heun"], + callback_data="heun")], [InlineKeyboardButton( - f"→ {LANG_TEXTS[current_language]["method_runge_kutta"]} ←", - callback_data="method_runge_kutta") - if current_method == "method_runge_kutta" else InlineKeyboardButton( - LANG_TEXTS[current_language]["method_runge_kutta"], - callback_data="method_runge_kutta")], + f"→ {LANG_TEXTS[current_language]["numerical_methods"]["runge_kutta"]} ←", + callback_data="runge_kutta") + if current_method == "runge_kutta" else InlineKeyboardButton( + LANG_TEXTS[current_language]["numerical_methods"]["runge_kutta"], + callback_data="runge_kutta")], [InlineKeyboardButton( - f"→ {LANG_TEXTS[current_language]["method_dormand_prince"]} ←", - callback_data="method_dormand_prince") - if current_method == "method_dormand_prince" else InlineKeyboardButton( - LANG_TEXTS[current_language]["method_dormand_prince"], - callback_data="method_dormand_prince")], + f"→ {LANG_TEXTS[current_language]["numerical_methods"]["dormand_prince"]} ←", + callback_data="dormand_prince") + if current_method == "dormand_prince" else InlineKeyboardButton( + LANG_TEXTS[current_language]["numerical_methods"]["dormand_prince"], + callback_data="dormand_prince")], [InlineKeyboardButton( LANG_TEXTS[current_language]["back"], callback_data="settings_back")] @@ -478,11 +478,11 @@ async def solve_history_details(update: Update, context: ContextTypes.DEFAULT_TY initial_y_str = str(initial_y) method_mapping = { - "euler": LANG_TEXTS[current_language]["method_euler"], - "midpoint": LANG_TEXTS[current_language]["method_midpoint"], - "heun": LANG_TEXTS[current_language]["method_heun"], - "rungeKutta": LANG_TEXTS[current_language]["method_runge_kutta"], - "dormandPrince": LANG_TEXTS[current_language]["method_dormand_prince"] + "euler": LANG_TEXTS[current_language]["numerical_methods"]["euler"], + "midpoint": LANG_TEXTS[current_language]["numerical_methods"]["midpoint"], + "heun": LANG_TEXTS[current_language]["numerical_methods"]["heun"], + "rungeKutta": LANG_TEXTS[current_language]["numerical_methods"]["runge_kutta"], + "dormandPrince": LANG_TEXTS[current_language]["numerical_methods"]["dormand_prince"] } method_display = method_mapping.get(method, method) @@ -959,7 +959,7 @@ def main() -> None: CallbackQueryHandler(settings_language, pattern="^settings_language$"), CallbackQueryHandler( method, - pattern="^method_(euler|midpoint|heun|runge_kutta|dormand_prince)$" + pattern="^(euler|midpoint|heun|runge_kutta|dormand_prince)$" ), CallbackQueryHandler(rounding, pattern="^(4|6|8|16)$"), CallbackQueryHandler(language, pattern="^(en|ru|zh)$"), diff --git a/solver-bot/src/main/python/spring_client.py b/solver-bot/src/main/python/spring_client.py index 3ae8057..e51e53e 100644 --- a/solver-bot/src/main/python/spring_client.py +++ b/solver-bot/src/main/python/spring_client.py @@ -15,11 +15,11 @@ async def set_parameters( initial_x, initial_y, reach_point, step_size ): method_mapping = { - "method_euler": "euler", - "method_midpoint": "midpoint", - "method_heun": "heun", - "method_runge_kutta": "rungeKutta", - "method_dormand_prince": "dormandPrince", + "euler": "euler", + "midpoint": "midpoint", + "heun": "heun", + "runge_kutta": "rungeKutta", + "dormand_prince": "dormandPrince", } payload = {