107 lines
4.3 KiB
Python
107 lines
4.3 KiB
Python
<|channel|>final code<|message|>import json
|
|
from pathlib import Path
|
|
from typing import List, Dict
|
|
|
|
from rich.console import Console
|
|
from rich.table import Table
|
|
|
|
console = Console()
|
|
|
|
|
|
def load_user_profile(path: str) -> Dict:
|
|
"""
|
|
Загружаем профиль пользователя из JSON‑файла.
|
|
Ожидается структура:
|
|
{
|
|
"name": "Иван",
|
|
"experience_level": "beginner", # beginner, intermediate, advanced
|
|
"interests": ["machine learning", "natural language processing"]
|
|
}
|
|
"""
|
|
try:
|
|
data = json.loads(Path(path).read_text(encoding="utf-8"))
|
|
console.print(f"[green]Профиль пользователя загружен: {data['name']}[/green]")
|
|
return data
|
|
except Exception as exc:
|
|
console.print(f"[red]Ошибка при чтении профиля: {exc}[/red]")
|
|
raise
|
|
|
|
|
|
def generate_plan(profile: Dict) -> List[Dict]:
|
|
"""
|
|
Генерируем план обучения на основе уровня опыта и интересов.
|
|
План состоит из этапов, каждый этап содержит название, описание и список задач.
|
|
"""
|
|
level = profile.get("experience_level", "beginner")
|
|
interests = profile.get("interests", [])
|
|
|
|
stages: List[Dict] = []
|
|
|
|
# Базовый набор тем
|
|
base_topics = {
|
|
"beginner": [
|
|
("Введение в искусственный интеллект", ["Понимание истории ИИ", "Основные понятия"]),
|
|
("Python для AI", ["Установка Anaconda", "Библиотеки NumPy, Pandas"]),
|
|
("Машинное обучение", ["Линейная регрессия", "Классификация"])
|
|
],
|
|
"intermediate": [
|
|
("Глубокое обучение", ["Нейронные сети", "ТензорFlow / PyTorch"]),
|
|
("Обработка естественного языка", ["Tokenization", "Word embeddings"]),
|
|
("Этика ИИ", ["Bias & fairness", "Privacy concerns"])
|
|
],
|
|
"advanced": [
|
|
("Сложные модели", ["Transformer architecture", "Reinforcement learning"]),
|
|
("Оптимизация и масштабирование", ["Distributed training", "GPU/TPU usage"]),
|
|
("Исследовательские проекты", ["Публикация статей", "Конференции"])
|
|
]
|
|
}
|
|
|
|
# Добавляем базовые темы
|
|
for title, tasks in base_topics.get(level, []):
|
|
stages.append({"title": title, "description": f"Основы {title.lower()}", "tasks": tasks})
|
|
|
|
# Добавляем интересные темы
|
|
if interests:
|
|
for interest in interests:
|
|
stages.append({
|
|
"title": f"Углубление в {interest.title()}",
|
|
"description": f"Продвинутый курс по {interest}",
|
|
"tasks": [f"Изучить ключевые статьи", f"Реализовать проект на тему {interest}"]
|
|
})
|
|
|
|
return stages
|
|
|
|
|
|
def display_plan(stages: List[Dict]) -> None:
|
|
"""
|
|
Выводим план в виде таблицы с помощью rich.
|
|
"""
|
|
table = Table(title="План личной AI‑грамотности", show_lines=True)
|
|
table.add_column("Этап", style="cyan", no_wrap=True)
|
|
table.add_column("Описание", style="magenta")
|
|
table.add_column("Задачи", style="green")
|
|
|
|
for stage in stages:
|
|
tasks = "\n".join(f"- {t}" for t in stage["tasks"])
|
|
table.add_row(stage["title"], stage["description"], tasks)
|
|
|
|
console.print(table)
|
|
|
|
|
|
def main():
|
|
"""
|
|
Точка входа. Ожидается путь к JSON‑файлу с профилем пользователя.
|
|
"""
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser(description="Генератор плана AI‑грамотности")
|
|
parser.add_argument("profile", help="Путь к файлу профиля пользователя (JSON)")
|
|
args = parser.parse_args()
|
|
|
|
profile = load_user_profile(args.profile)
|
|
plan = generate_plan(profile)
|
|
display_plan(plan)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |