ItamarMordo commited on
Commit
491177a
·
verified ·
1 Parent(s): 3f173e5

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +19 -12
server.py CHANGED
@@ -98,23 +98,30 @@ def expand_query(query: str) -> List[str]:
98
  def simplify_schematic_text(text: str) -> str:
99
  # 1. ניקוי שמות רכיבים טכניים מה-DB החדש
100
  text = text.replace("ESP32-DEVKITC-32D_ESP32-DEVKITC-30GPIO", "בקר ESP32")
101
- text = text.replace("LevelConvertor", "ממיר רמות") # חשוב: הסרת השם באנגלית
102
- text = text.replace("BOB_19002", "") # הסרת המק\"ט המיותר
103
- text = text.replace("StudentBoard", "הלוח הראשי")
 
 
 
 
 
 
 
 
 
104
  text = text.replace("0201080606", "")
105
  text = text.replace("040709_0804060105", "")
106
 
107
- # 2. ניקוי שמות גנריים
108
- text = text.replace("LCD1 (NEXTION)", "מסך המגע")
109
- text = text.replace("HMI (NEXTION)", "מסך המגע")
110
- text = text.replace("HMI", "המסך")
111
- text = text.replace("NEXTION", "המסך")
112
 
113
- # 3. ניקוי שאריות
114
- text = text.replace("()", "") # הסרת סוגריים ריקים שנשארו
115
- text = text.replace(" ", " ") # הסרת רווחים כפולים
116
 
117
- # 4. תרגום פעלים
118
  text = text.replace("connects to", "מחובר אל")
119
  text = text.replace("Pin", "פין")
120
 
 
98
  def simplify_schematic_text(text: str) -> str:
99
  # 1. ניקוי שמות רכיבים טכניים מה-DB החדש
100
  text = text.replace("ESP32-DEVKITC-32D_ESP32-DEVKITC-30GPIO", "בקר ESP32")
101
+
102
+ # Specific component mappings based on your schematic
103
+ # We map the ID to a readable name but KEEP the ID for reference
104
+ text = re.sub(r"U2\b", "ESP32 (U2)", text)
105
+ text = re.sub(r"U4\b", "Level Shifter (U4)", text)
106
+ text = re.sub(r"U3\b", "Main Board (U3)", text)
107
+ text = re.sub(r"LCD1\b", "Nextion Screen (LCD1)", text)
108
+
109
+ # Clean up the raw database strings if they still exist
110
+ text = text.replace("LevelConvertor (BOB_19002)", "Level Shifter (U4)")
111
+ text = text.replace("BOB_19002", "")
112
+ text = text.replace("StudentBoard (0201080606)", "Main Board (U3)")
113
  text = text.replace("0201080606", "")
114
  text = text.replace("040709_0804060105", "")
115
 
116
+ # 2. Clean Generic names
117
+ text = text.replace("(NEXTION)", "")
118
+ text = text.replace("HMI", "")
 
 
119
 
120
+ # 3. Clean up syntax
121
+ text = text.replace("()", "") # Remove empty brackets
122
+ text = text.replace(" ", " ") # Remove double spaces
123
 
124
+ # 4. Translate verbs for the Hebrew sentence structure
125
  text = text.replace("connects to", "מחובר אל")
126
  text = text.replace("Pin", "פין")
127