AI prompt
This commit is contained in:
@@ -892,6 +892,14 @@ class SchoolScheduleDB:
|
||||
# Check if it looks like a name with multiple capitalized words (Russian or English)
|
||||
# Teacher names typically have 2-4 words with capitalized first letters
|
||||
words = text.split()
|
||||
|
||||
# Handle compound names like "Name1 / Name2"
|
||||
if '/' in text:
|
||||
parts = [part.strip() for part in text.split('/')]
|
||||
for part in parts:
|
||||
if self._is_likely_teacher_name_simple(part):
|
||||
return True
|
||||
|
||||
if len(words) < 2 or len(words) > 4:
|
||||
return False
|
||||
|
||||
@@ -957,6 +965,7 @@ class SchoolScheduleDB:
|
||||
def update_teachers_from_cheat_sheet(self, teachers_csv_path):
|
||||
"""Update the teachers table from the Teachers.csv file"""
|
||||
import csv
|
||||
import re
|
||||
|
||||
with open(teachers_csv_path, 'r', encoding='utf-8') as file:
|
||||
reader = csv.reader(file)
|
||||
@@ -966,23 +975,51 @@ class SchoolScheduleDB:
|
||||
unique_teachers = set()
|
||||
|
||||
# Process the CSV to extract teacher names
|
||||
# Teacher names appear in positions after subjects and before group info
|
||||
for row in rows:
|
||||
# Process the row in triplets (subject, teacher, group_info) pattern
|
||||
j = 0
|
||||
while j < len(row) - 2:
|
||||
# Look for a subject-like cell followed by a teacher-like cell
|
||||
subject_cell = str(row[j]).strip() if j < len(row) else ""
|
||||
teacher_cell = str(row[j + 1]).strip() if j + 1 < len(row) else ""
|
||||
group_cell = str(row[j + 2]).strip() if j + 2 < len(row) else ""
|
||||
|
||||
# Check if middle cell is likely a teacher name (between subject and group)
|
||||
if (subject_cell and self._is_likely_subject_name_simple(subject_cell) and
|
||||
teacher_cell and self._is_likely_teacher_name_enhanced(teacher_cell) and
|
||||
group_cell and self._is_likely_group_identifier(group_cell)):
|
||||
|
||||
# Handle composite teacher names like "Name1 / Name2"
|
||||
if '/' in teacher_cell:
|
||||
parts = [part.strip() for part in teacher_cell.split('/')]
|
||||
for part in parts:
|
||||
if self._is_likely_teacher_name_enhanced(part):
|
||||
unique_teachers.add(part)
|
||||
else:
|
||||
unique_teachers.add(teacher_cell)
|
||||
|
||||
# Also check if the current cell itself might be a teacher name
|
||||
current_cell = str(row[j]).strip()
|
||||
if current_cell and self._is_likely_teacher_name_enhanced(current_cell):
|
||||
unique_teachers.add(current_cell)
|
||||
|
||||
j += 1 # Move to next cell
|
||||
|
||||
# Special handling for teacher names that appear in combination patterns like "First Last / Other Teacher"
|
||||
for row in rows:
|
||||
for cell in row:
|
||||
cell = cell.strip()
|
||||
# Check if the cell looks like a teacher name (Russian/English name format)
|
||||
if self._is_likely_teacher_name_enhanced(cell):
|
||||
unique_teachers.add(cell)
|
||||
|
||||
# Also check for names that might be combined with "/" (like "Name1 / Name2")
|
||||
if '/' in cell:
|
||||
parts = [part.strip() for part in cell.split('/')]
|
||||
cell_str = str(cell).strip()
|
||||
if '/' in cell_str:
|
||||
parts = [part.strip() for part in cell_str.split('/')]
|
||||
for part in parts:
|
||||
part = part.strip()
|
||||
if self._is_likely_teacher_name_enhanced(part):
|
||||
unique_teachers.add(part)
|
||||
|
||||
# Insert unique teachers into the database
|
||||
for teacher_name in unique_teachers:
|
||||
if teacher_name: # Make sure it's not an empty string
|
||||
if teacher_name and len(teacher_name) > 2: # Make sure it's not an empty string or very short
|
||||
self.cursor.execute(
|
||||
"INSERT OR IGNORE INTO teachers (name, email, phone) VALUES (?, NULL, NULL)",
|
||||
(teacher_name,)
|
||||
|
||||
Reference in New Issue
Block a user