-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCaseReasonmingMethod.py
89 lines (78 loc) · 3.22 KB
/
CaseReasonmingMethod.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@ String level : Info/Error
@ String msg : The message you want to show
"""
import codecs
import datetime
from os import path
from DSMCaseReasoning import CaseReasoning as DSMcr
from RFCaseReasoning import CaseReasoning as RFcr
def echoMsg(self, level, msg, timestr=datetime.datetime.now().strftime('%Y.%m.%d-%H:%M:%S')):
logFilePath = path.dirname(path.dirname(__file__)) + '/log.txt'
f = codecs.open(logFilePath, 'a', 'utf-8')
if level == 'Info':
str = '[Info] %s\n[Time] %s' % (msg, timestr)
self.printInfo(str)
self.printInfo('-------------------------')
f.write('[Info] %s\r\n[Time] %s\r\n' % (msg, timestr))
f.write('-------------------------\r\n')
elif level == 'Error':
str = '[Error] %s\n[Time] %s' % (msg, timestr)
self.printInfo(str)
self.printInfo('-------------------------')
f.write('[Error] %s\r\n[Time] %s\r\n' % (msg, timestr))
f.write('-------------------------\r\n')
f.close()
def caseParsing(data, null=None):
'''
step1:解析data
step2:根据dsm解析数据,因为不同的任务解析模板是不一样的,例如dsm需要studyArea,up,down,property。从转换的字典里找
step3:将解析的数据输入相应的推理方法,如DSMCaseReasoning,RFCaseReasoning
:return: 结果为推荐的环境变量,格式为字典
'''
#step1:解析数据
model = data['model']
arg = data['arg']
result = null
# step2:选择model
if model == 'iPSM':
studyArea = data['studyArea']
if studyArea is not None and (studyArea[0] >= studyArea[1] or studyArea[2] <= studyArea[3]):
return 'invalid input study area'
#step3:将解析的数据输入相应的推理方法
result = DSMcr.DSMCaseReasoning(studyArea, arg)
elif model == 'RF':
studyArea = data['studyArea']
# step3:将解析的数据输入相应的推理方法
result = RFcr.RFCaseReasoning(studyArea, arg)
return result
#return #结果字典
def caseParsingEGC(data, null=None):
'''
step1:解析data
step2:根据dsm解析数据,因为不同的任务解析模板是不一样的,例如dsm需要studyArea,up,down,property。从转换的字典里找
step3:将解析的数据输入相应的推理方法,如DSMCaseReasoning,RFCaseReasoning
:return: 结果为推荐的环境变量,格式为字典
'''
#step1:解析数据
model = data['model']
arg = data['arg']
result = null
# step2:选择model
if model == 'iPSM':
studyArea = data['studyArea']
if studyArea is not None:
newArea=[studyArea[0], studyArea[0],studyArea[1],studyArea[1]]
#return 'invalid input study area'
#step3:将解析的数据输入相应的推理方法
result = DSMcr.DSMCaseReasoning(newArea, arg)
else:
return 'invalid input study area'
elif model == 'RF':
studyArea = data['studyArea']
# step3:将解析的数据输入相应的推理方法
result = RFcr.RFCaseReasoning(studyArea, arg)
return result
#return #结果字典