diff --git a/app/ai.py b/app/ai.py
index 0155299..fedf09f 100644
--- a/app/ai.py
+++ b/app/ai.py
@@ -74,10 +74,6 @@ def get_sentence_dictionary_hints(sentence: str, target_word: str = "") -> str:
return ""
hints = []
- special_guidance = {
- "owl": "owl — это сова/неясыть (ни в коем случае НЕ орёл!)",
- "tawny owl": "tawny owl — это сова/неясыть (птица семейства совиных, ни в коем случае НЕ орёл!)",
- }
try:
with get_db() as conn:
@@ -98,11 +94,7 @@ def get_sentence_dictionary_hints(sentence: str, target_word: str = "") -> str:
continue
seen_terms.add(cand)
trans = matched_dict[cand]
- guidance = special_guidance.get(cand, "")
- if guidance:
- hints.append(f"- {cand}: {trans} (ВНИМАНИЕ: {guidance})")
- else:
- hints.append(f"- {cand}: {trans}")
+ hints.append(f"- {cand}: {trans}")
if len(hints) >= 8:
break
diff --git a/app/reader.py b/app/reader.py
index 55983d7..8168fbb 100644
--- a/app/reader.py
+++ b/app/reader.py
@@ -286,44 +286,6 @@ def split_long_text(text: str, target_words: int = 3000) -> List[str]:
return chunks
-
-def parse_text(content: str, title: str = "Untitled", author: str = "") -> Tuple[str, str, List[Dict[str, str]]]:
- """
- Parses plain text or Markdown into readable chapters.
- Splits by explicit chapter markers (e.g. 'Chapter X', '# Chapter') or chunks of ~3000 words.
- """
- content = content.replace("\r\n", "\n").replace("\r", "\n").strip()
- if not content:
- return title, author, [{"title": title if title != "Untitled" else "Chapter 1", "content": ""}]
-
- lines = content.split("\n")
- first_line = lines[0].strip()
-
- # Extract title from first line or # Heading /
if default or generic README
- if title == "Untitled" or title.lower().startswith("readme"):
- if first_line.startswith("# "):
- title = first_line.lstrip("# ").strip()
- if len(lines) > 1:
- content = "\n".join(lines[1:]).strip()
- elif first_line.lower().startswith("title:"):
- title = first_line.split(":", 1)[1].strip()
- if len(lines) > 1:
- content = "\n".join(lines[1:]).strip()
- else:
- h1_match = re.search(r"]*>(.*?)
", content[:1500], re.IGNORECASE)
- if h1_match:
- detected = re.sub(r"<[^>]+>", "", h1_match.group(1)).strip()
- if detected:
- title = detected
-
- # Extract author from next line if missing
- if not author:
- lines = content.split("\n")
- if lines and lines[0].lower().startswith(("author:", "by:")):
- author = lines[0].split(":", 1)[1].strip()
- if len(lines) > 1:
- content = "\n".join(lines[1:]).strip()
-
def detect_text_headings(content: str) -> List[Dict]:
"""
Detects section and chapter headings with high accuracy across Markdown,
diff --git a/app/tasks.py b/app/tasks.py
index b3d418b..ba351d7 100644
--- a/app/tasks.py
+++ b/app/tasks.py
@@ -49,54 +49,24 @@ def update_task_progress(
"""
Updates the progress and status of a running task.
"""
- if total is not None and message is not None:
- conn.execute(
- """
- UPDATE background_tasks
- SET status = 'running',
- progress_current = ?,
- progress_total = ?,
- message = ?,
- updated_at = CURRENT_TIMESTAMP
- WHERE id = ? AND status != 'cancelled'
- """,
- (current, total, message, task_id),
- )
- elif total is not None:
- conn.execute(
- """
- UPDATE background_tasks
- SET status = 'running',
- progress_current = ?,
- progress_total = ?,
- updated_at = CURRENT_TIMESTAMP
- WHERE id = ? AND status != 'cancelled'
- """,
- (current, total, task_id),
- )
- elif message is not None:
- conn.execute(
- """
- UPDATE background_tasks
- SET status = 'running',
- progress_current = ?,
- message = ?,
- updated_at = CURRENT_TIMESTAMP
- WHERE id = ? AND status != 'cancelled'
- """,
- (current, message, task_id),
- )
- else:
- conn.execute(
- """
- UPDATE background_tasks
- SET status = 'running',
- progress_current = ?,
- updated_at = CURRENT_TIMESTAMP
- WHERE id = ? AND status != 'cancelled'
- """,
- (current, task_id),
- )
+ set_clauses = ["status = 'running'", "progress_current = ?", "updated_at = CURRENT_TIMESTAMP"]
+ params: List[Any] = [current]
+
+ if total is not None:
+ set_clauses.append("progress_total = ?")
+ params.append(total)
+
+ if message is not None:
+ set_clauses.append("message = ?")
+ params.append(message)
+
+ params.append(task_id)
+ sql = f"""
+ UPDATE background_tasks
+ SET {', '.join(set_clauses)}
+ WHERE id = ? AND status != 'cancelled'
+ """
+ conn.execute(sql, params)
def complete_task(