You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB

5 months ago
from Text2Sql.Util.VannaUtil import *
5 months ago
5 months ago
'''
经验
1尽量使用宽表少用关联越少越好
2应该有一些固定的组合用法预置出来给出范例让用户可以简单修改后就能使用
3应该有类似于 保存为用例查询历史等功能让用户方便利旧
'''
4 months ago
5 months ago
if __name__ == "__main__":
5 months ago
vn = VannaUtil()
5 months ago
# 开始训练
print("开始训练...")
5 months ago
# 打开AreaSchoolLesson.sql文件内容
4 months ago
with open("Sql/AreaSchoolLessonDDL.sql", "r", encoding="utf-8") as file:
5 months ago
ddl = file.read()
# 训练数据
vn.train(
ddl=ddl
)
4 months ago
# 添加有关业务术语或定义的文档
4 months ago
# vn.train(documentation="Sql/AreaSchoolLesson.md")
4 months ago
# 使用 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):
4 months ago
vn.train(sql=comment.strip() + '\n' + sql.strip() + '\n')
4 months ago
5 months ago