MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / check_doc

Function check_doc

bmtools/tools/meta_analysis/api.py:122–159  ·  view source on GitHub ↗
(til, doc, ques)

Source from the content-addressed store, hash-verified

120 return 1
121
122def check_doc(til, doc, ques):
123 string = ""
124 for idx, que in enumerate(ques):
125 string+=str(idx+1)+'. '+que+' Why? '
126 prp="""Read the following article and answer the questions.
127 [Article]
128
129 """
130 prp+=til+'. '+doc[:10000]
131 prp+="[Questions] "+string
132 lt = len(prp.split(' '))
133 response = generate_response(prp, 4000-2*lt)
134 orig = response.strip('\n')
135 #print('Title: ', til, ', Check: ', orig.replace('\n', ' '))
136 cnt = 2
137 preds = []
138 orig = ' '+orig.replace('\n', ' ')
139 if orig.find(' 1. ')>-1:
140 orig = orig.split(' 1. ')[-1]
141 while orig.find(' '+str(cnt)+'. ')>-1:
142 pred = orig.split(' '+str(cnt)+'. ')[0]
143 preds.append(pred)
144 orig = orig.split(' '+str(cnt)+'. ')[-1]
145 cnt+=1
146 preds.append(orig)
147 else:
148 preds = [orig]
149 sm = 0
150 prob = []
151 for idx,pred in enumerate(preds):
152 if judge(pred):
153 sm+=1
154 else:
155 if idx<len(ques):
156 prob.append([ques[idx],pred])
157 sm=float(sm)/float(len(preds))
158 #print('Score: ', sm)
159 return sm, prob
160
161def draw_conclusion(topic, allcon):
162 prp = 'We want to explore '+topic+'. Read the analysis table for several articles and summarize your conclusion. # Table: '+'\n'+allcon+'\n # Conclusion: '

Callers 1

literature_filterFunction · 0.85

Calls 2

generate_responseFunction · 0.85
judgeFunction · 0.85

Tested by

no test coverage detected