main
HuangHai 4 months ago
parent e82aaf68b0
commit b0a6e29ef7

@ -0,0 +1 @@
# 行政区划名,行政区,区域名称区域一般是同一个概念查询表t_crawler_lesson中字段gather_regionc

@ -0,0 +1,24 @@
/*
:
12024
2
3: ,,,
*/
SELECT stage_name AS , subject_name AS , ROW_NUMBER() OVER (PARTITION BY stage_name ORDER BY COUNT(*) DESC) AS , COUNT(*) AS FROM t_crawler_lesson WHERE publish_time >= '2024-01-01' AND publish_time < '2025-01-01' AND gather_regionc IS NOT NULL AND gather_regionc <> '' GROUP BY stage_name, subject_name ORDER BY stage_name, DESC;
/*
:
12024
2
3: ,,,,
*/
SELECT gather_regionc AS , stage_name AS , ROW_NUMBER() OVER (PARTITION BY gather_regionc ORDER BY COUNT(*) DESC) AS , teacher_school_name AS , COUNT(*) AS FROM t_crawler_lesson WHERE publish_time >= '2024-01-01' AND publish_time < '2025-01-01' AND gather_regionc IS NOT NULL AND gather_regionc != '' GROUP BY gather_regionc, stage_name, teacher_school_name ORDER BY gather_regionc, COUNT(*) DESC;
/*
:
12024
2
3: ,,,,,
*/
SELECT gather_regionc AS , stage_name AS , ROW_NUMBER() OVER (PARTITION BY gather_regionc ORDER BY COUNT(*) DESC) AS , teacher_school_name AS , EXTRACT(YEAR FROM publish_time) AS , COUNT(*) AS FROM t_crawler_lesson WHERE publish_time >= '2024-01-01' AND publish_time < '2025-01-01' AND gather_regionc = '二道区' AND gather_regionc IS NOT NULL AND gather_regionc != '' GROUP BY gather_regionc, stage_name, teacher_school_name, EXTRACT(YEAR FROM publish_time) ORDER BY gather_regionc, DESC;

@ -42,8 +42,8 @@ def generate_sql_from_prompt(ddl: str, prompt: str) -> str:
raise ValueError("未能生成 SQL 查询")
if __name__ == '__main__':
# 读取 Sql/AreaSchoolLesson.sql 文件
with open("../Sql/AreaSchoolLesson.sql", "r", encoding="utf-8") as file:
# 读取 Sql/AreaSchoolLessonDDL.sql 文件
with open("../Sql/AreaSchoolLessonDDL.sql", "r", encoding="utf-8") as file:
ddl = file.read()
# 自然语言描述

@ -21,14 +21,26 @@ if __name__ == "__main__":
# 开始训练
print("开始训练...")
# 打开AreaSchoolLesson.sql文件内容
with open("Sql/AreaSchoolLesson.sql", "r", encoding="utf-8") as file:
with open("Sql/AreaSchoolLessonDDL.sql", "r", encoding="utf-8") as file:
ddl = file.read()
# 训练数据
vn.train(
ddl=ddl
)
# 添加有关业务术语或定义的文档
vn.train(documentation="Sql/AreaSchoolLesson.md")
# 使用 SQL 进行训练
# 读取 SQL 文件
with open('Sql/AreaSchoolLessonGenerate.sql', 'r', encoding='utf-8') as file:
sql_content = file.read()
# 使用正则表达式提取注释和 SQL 语句
sql_pattern = r'/\*(.*?)\*/(.*?);'
sql_snippets = re.findall(sql_pattern, sql_content, re.DOTALL)
# 打印提取的注释和 SQL 语句
for i, (comment, sql) in enumerate(sql_snippets, 1):
vn.train(sql=comment.strip() + '\n' + sql.strip()+'\n')
# 自然语言提问
# 整体情况

Loading…
Cancel
Save