获取小闲答题纸有效列的机制改进, 现已能识别大型考试

This commit is contained in:
weiye.wang 2024-06-18 06:55:19 +08:00
parent c1bbc7fad8
commit 4759c20103
1 changed files with 14 additions and 11 deletions

View File

@ -2732,19 +2732,22 @@ def CheckPaperType(filepath,filename): #根据filepath(通常是小闲的zip解
def generateColIndexandMarks(filepath,statsfilename,paperinfo): #根据filepath(是一个有statsfilename的文件夹列表)中第一个路径中的数据文件, statsfilename数据文件名, 及paperinfo(FindPaper返回的结果)寻找excel文件中有效的列的位置和相应的满分分数 def generateColIndexandMarks(filepath,statsfilename,paperinfo): #根据filepath(是一个有statsfilename的文件夹列表)中第一个路径中的数据文件, statsfilename数据文件名, 及paperinfo(FindPaper返回的结果)寻找excel文件中有效的列的位置和相应的满分分数
dir = filepath[0] dir = filepath[0]
dfcurrent = pd.read_excel(os.path.join(dir,statsfilename)) dfcurrent = pd.read_excel(os.path.join(dir,statsfilename))
validcols = [] excludecols = []
for i in range(len(dfcurrent.columns)): for i in range(len(dfcurrent.columns)):
colname = str(dfcurrent.iloc[1,i]) colname = str(dfcurrent.iloc[1,i])
if ("单选" in colname or "多选" in colname or "填空" in colname or "主观" in colname or "" in colname ) and re.findall("[ABCD]",colname) == []: if re.findall("[A-Z]",colname) != []:
validcols.append(i) excludecols.append(i)
for col in range(len(validcols)-1,-1,-1): validcoldict = {}
colname = str(dfcurrent.iloc[1,validcols[col]]) for i in range(len(dfcurrent.columns)):
if "主观" in colname: colname = str(dfcurrent.iloc[1,i])
colname_main = re.findall(r"^([\d\.]*)[\($]",colname[2:])[0] digname = re.findall(r"[\d\.]+",colname)
t = [dfcurrent.iloc[1,c] for c in validcols[col+1:]] if len(digname) > 0 and not i in excludecols:
t = str(t) if not i-1 in validcoldict or not validcoldict[i-1] in digname[0]:
if colname_main in t: validcoldict[i] = digname[0]
validcols.pop(col) else:
validcoldict.pop(i-1)
validcoldict[i] = digname[0]
validcols = list(validcoldict.keys())
if paperinfo[3] == []: if paperinfo[3] == []:
marks = [1] * len(validcols) marks = [1] * len(validcols)
else: else: