245 lines
8.7 KiB
Python
245 lines
8.7 KiB
Python
import string
|
|
|
|
punc = string.punctuation
|
|
|
|
|
|
def choose_model(content, flag_asr):
|
|
Trigger = ["号模型", "个模型"]
|
|
err_dict = {"默巡": "模型", "魔巡": "模型", "不型": "模型", "魔生": "模型", "不胜": "模型", "摸胸": "模型", "陌生": "模型",
|
|
"某旋": "模型", "不醒": "模型", "不省": "模型", "卧型": "模型", "播行": "模型", "魔胸": "模型", "不行": "模型",
|
|
"陌型": "模型", "魔型": "模型"}
|
|
for i in err_dict.keys():
|
|
if i in content:
|
|
content = content.replace(i, err_dict[i])
|
|
start_index = 0
|
|
pos_list = []
|
|
model_num = []
|
|
for i in Trigger:
|
|
if i in content:
|
|
while True:
|
|
pos = content.find(i, start_index)
|
|
if pos != -1:
|
|
start_index = pos + 1
|
|
pos_list.append(pos)
|
|
if pos == -1:
|
|
break
|
|
start_index = 0
|
|
if pos_list and 0 not in pos_list:
|
|
flag_asr = 100
|
|
for i in pos_list:
|
|
num_end_flag = False
|
|
param_1 = ''
|
|
for j in range(start_index, i + 1):
|
|
if content[j].isdecimal():
|
|
temp = content[j]
|
|
param_1 = param_1 + temp
|
|
if not content[j + 1].isdecimal():
|
|
num_end_flag = True
|
|
if num_end_flag:
|
|
start_index = i
|
|
break
|
|
model_num.append(param_1)
|
|
return model_num, flag_asr
|
|
|
|
|
|
def Move(content, flag_asr):
|
|
Trigger1 = ["移动", "平移"]
|
|
Trigger2 = ["移动到", "平移到", "移动至", "移至"]
|
|
Param = ["x", "y", "z"]
|
|
err_dict = {"外轴": "y轴", "歪轴": "y轴", "移动置": "移动至", "移置": "移至"}
|
|
err_message = ''
|
|
check_param = False
|
|
for i in err_dict.keys():
|
|
if i in content:
|
|
content = content.replace(i, err_dict[i])
|
|
model_param = []
|
|
for i in Trigger1:
|
|
if i in content:
|
|
flag_asr = 8
|
|
check_param = True
|
|
for i in Trigger2:
|
|
if i in content:
|
|
flag_asr = 9
|
|
check_param = True
|
|
if check_param:
|
|
param_1 = ''
|
|
param_2 = ''
|
|
param_3 = ''
|
|
pos1 = content.rfind(Param[0])
|
|
pos2 = content.rfind(Param[1])
|
|
pos3 = content.rfind(Param[2])
|
|
num_end_flag = False
|
|
if pos1 == -1 and pos2 == -1 and pos3 == -1:
|
|
err_message = "请明确指定x,y,z的方向或具体坐标"
|
|
|
|
if pos1 != -1:
|
|
for j in range(pos1 + 1, len(content)):
|
|
if content[j].isdecimal() or content[j] in punc:
|
|
temp = content[j]
|
|
param_1 = param_1 + temp
|
|
if j == len(content) - 1 or (not content[j + 1].isdecimal() and not content[j + 1] in punc):
|
|
num_end_flag = True
|
|
if num_end_flag:
|
|
num_end_flag = False
|
|
break
|
|
|
|
if pos2 != -1:
|
|
for j in range(pos2 + 1, len(content)):
|
|
if content[j].isdecimal() or content[j] in punc:
|
|
temp = content[j]
|
|
param_2 = param_2 + temp
|
|
if j == len(content) - 1 or (not content[j + 1].isdecimal() and not content[j + 1] in punc):
|
|
num_end_flag = True
|
|
if num_end_flag:
|
|
num_end_flag = False
|
|
break
|
|
|
|
if pos3 != -1:
|
|
for j in range(pos3 + 1, len(content)):
|
|
if content[j].isdecimal() or content[j] in punc:
|
|
temp = content[j]
|
|
param_3 = param_3 + temp
|
|
if j == len(content) - 1 or (not content[j + 1].isdecimal() and not content[j + 1] in punc):
|
|
num_end_flag = True
|
|
if num_end_flag:
|
|
break
|
|
if param_3 == '':
|
|
param_3 = '0'
|
|
if param_2 == '':
|
|
param_2 = '0'
|
|
if param_1 == '':
|
|
param_1 = '0'
|
|
model_param = [param_1, param_2, param_3]
|
|
print(model_param)
|
|
return model_param, flag_asr, err_message
|
|
|
|
|
|
def Rotation(content, flag_asr):
|
|
Trigger = ["旋转"]
|
|
Param = ["x", "y", "z", "度"]
|
|
err_dict = {"外轴": "y轴", "歪轴": "y轴"}
|
|
err_message = ''
|
|
for i in err_dict.keys():
|
|
if i in content:
|
|
content = content.replace(i, err_dict[i])
|
|
model_param = []
|
|
for i in Trigger:
|
|
if i in content:
|
|
param_1 = ''
|
|
param_2 = ''
|
|
param_3 = ''
|
|
flag_asr = 10
|
|
pos1 = content.rfind(Param[0])
|
|
pos2 = content.rfind(Param[1])
|
|
pos3 = content.rfind(Param[2])
|
|
num_end_flag = False
|
|
if pos1 == -1 and pos2 == -1 and pos3 == -1:
|
|
pos1 = content.rfind(Param[3])
|
|
for j in reversed(range(0, pos1)):
|
|
if content[j].isdecimal() or content[j] in punc:
|
|
temp = content[j]
|
|
param_1 = temp + param_1
|
|
if j == 0 or (not content[j - 1].isdecimal() and not content[j - 1] in punc):
|
|
num_end_flag = True
|
|
if num_end_flag:
|
|
break
|
|
if pos1 != -1:
|
|
for j in range(pos1 + 1, len(content)):
|
|
if content[j].isdecimal() or content[j] in punc:
|
|
temp = content[j]
|
|
param_1 = param_1 + temp
|
|
if j == len(content) - 1 or (not content[j + 1].isdecimal() and not content[j + 1] in punc):
|
|
num_end_flag = True
|
|
if num_end_flag:
|
|
num_end_flag = False
|
|
break
|
|
|
|
if pos2 != -1:
|
|
for j in range(pos2 + 1, len(content)):
|
|
if content[j].isdecimal() or content[j] in punc:
|
|
temp = content[j]
|
|
param_2 = param_2 + temp
|
|
if j == len(content) - 1 or (not content[j + 1].isdecimal() and not content[j + 1] in punc):
|
|
num_end_flag = True
|
|
if num_end_flag:
|
|
num_end_flag = False
|
|
break
|
|
|
|
if pos3 != -1:
|
|
for j in range(pos3 + 1, len(content)):
|
|
if content[j].isdecimal() or content[j] in punc:
|
|
temp = content[j]
|
|
param_3 = param_3 + temp
|
|
if j == len(content) - 1 or (not content[j + 1].isdecimal() and not content[j + 1] in punc):
|
|
num_end_flag = True
|
|
if num_end_flag:
|
|
break
|
|
if param_3 == '':
|
|
param_3 = '0'
|
|
if param_2 == '':
|
|
param_2 = '0'
|
|
if param_1 == '':
|
|
param_1 = '0'
|
|
model_param = [param_1, param_2, param_3]
|
|
return model_param, flag_asr, err_message
|
|
|
|
|
|
def Mirror(content, flag_asr):
|
|
Trigger = ["镜像", "翻转", "反转"]
|
|
model_param = []
|
|
err_dict = {"xy": "xoy", "yz": "yoz", "xz": "xoz", "金上": "镜像", "坐近向": "做镜像", "镜下": "镜像", "镜相": "镜像"
|
|
, "xooy": "xoy", "yooz": "yoz", "xooz": "xoz", "景象": "镜像"}
|
|
err_message = ''
|
|
for i in err_dict.keys():
|
|
if i in content:
|
|
content = content.replace(i, err_dict[i])
|
|
print(content)
|
|
for i in Trigger:
|
|
if i in content:
|
|
param_1 = '1'
|
|
param_2 = '0'
|
|
param_3 = '0'
|
|
flag_asr = 11
|
|
if "xoy" in content:
|
|
param_1 = '1'
|
|
param_2 = '0'
|
|
param_3 = '0'
|
|
if "xoz" in content:
|
|
param_1 = '0'
|
|
param_2 = '1'
|
|
param_3 = '0'
|
|
if "yoz" in content:
|
|
param_1 = '0'
|
|
param_2 = '0'
|
|
param_3 = '1'
|
|
model_param = [param_1, param_2, param_3]
|
|
print(model_param)
|
|
return model_param, flag_asr, err_message
|
|
|
|
|
|
def Summation(content, flag_asr):
|
|
Trigger = ["求和", "球合", "求合", "球核"]
|
|
for i in Trigger:
|
|
if i in content:
|
|
flag_asr = 12
|
|
break
|
|
return flag_asr
|
|
|
|
|
|
def Difference(content, flag_asr):
|
|
Trigger = ["求差", "减"]
|
|
for i in Trigger:
|
|
if i in content:
|
|
flag_asr = 13
|
|
break
|
|
return flag_asr
|
|
|
|
|
|
def Intersection(content, flag_asr):
|
|
Trigger = ["求交", "交集", "相交"]
|
|
for i in Trigger:
|
|
if i in content:
|
|
flag_asr = 14
|
|
break
|
|
return flag_asr
|