Heng2004 commited on
Commit
7171447
Β·
verified Β·
1 Parent(s): a60d307

Create qa_store.py

Browse files
Files changed (1) hide show
  1. qa_store.py +32 -0
qa_store.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # qa_store.py
2
+ from typing import List, Dict, Any
3
+ import re
4
+
5
+ # Textbook chunks
6
+ ENTRIES: List[Dict[str, Any]] = []
7
+ RAW_KNOWLEDGE: str = ""
8
+
9
+ # QA from textbook JSONL
10
+ AUTO_QA_KNOWLEDGE: List[Dict[str, Any]] = []
11
+
12
+ # Manual QA managed by teacher
13
+ MANUAL_QA_LIST: List[Dict[str, Any]] = []
14
+ MANUAL_QA_INDEX: Dict[str, Dict[str, Any]] = {}
15
+
16
+ # Combined index for fast lookup
17
+ QA_INDEX: Dict[str, str] = {}
18
+ ALL_QA_KNOWLEDGE: List[Dict[str, Any]] = []
19
+
20
+ # Counter for new manual IDs
21
+ NEXT_MANUAL_ID: int = 1
22
+
23
+
24
+ def normalize_question(q: str) -> str:
25
+ """
26
+ Normalize Lao/English question text for matching.
27
+ Lowercase + remove punctuation + collapse spaces.
28
+ """
29
+ q = (q or "").lower()
30
+ q = re.sub(r"[?!?!\.\,\:\;\"β€œβ€'β€˜β€™]", " ", q)
31
+ q = re.sub(r"\s+", " ", q)
32
+ return q.strip()