madhiemw commited on
Commit
007fbf5
·
verified ·
1 Parent(s): 4e92f98

Update utils/regex.py

Browse files
Files changed (1) hide show
  1. utils/regex.py +27 -24
utils/regex.py CHANGED
@@ -1,24 +1,27 @@
1
- import re
2
-
3
- def remove_table_and_text(text):
4
- pattern = r"#table.*"
5
- if not re.search(pattern, text, re.DOTALL):
6
- return False
7
- cleaned_text = re.sub(pattern, "", text, flags=re.DOTALL).strip()
8
- return cleaned_text
9
-
10
-
11
- def extract_sql_query(text):
12
- """Extract and clean up SQL query from the response text"""
13
- match = re.search(r'```sql\n(.*?)```', text, re.DOTALL)
14
- if match:
15
- return match.group(1).strip()
16
- return None
17
- import re
18
-
19
- def detect_none_in_text(text: str) -> bool:
20
- if not text:
21
- return False
22
-
23
- pattern = r"None"
24
- return bool(re.search(pattern, text))
 
 
 
 
1
+ import re
2
+
3
+ def remove_table_and_text(text):
4
+ pattern = r"#table.*"
5
+ if not re.search(pattern, text, re.DOTALL):
6
+ return False
7
+ cleaned_text = re.sub(pattern, "", text, flags=re.DOTALL).strip()
8
+ return cleaned_text
9
+
10
+ def remove_unnecesery_table(text):
11
+ result = re.sub(r'\|.*', '', text).strip()
12
+ return result
13
+
14
+ def extract_sql_query(text):
15
+ """Extract and clean up SQL query from the response text"""
16
+ match = re.search(r'```sql\n(.*?)```', text, re.DOTALL)
17
+ if match:
18
+ return match.group(1).strip()
19
+ return None
20
+ import re
21
+
22
+ def detect_none_in_text(text: str) -> bool:
23
+ if not text:
24
+ return False
25
+
26
+ pattern = r"None"
27
+ return bool(re.search(pattern, text))