获取小闲答题纸有效列的机制改进, 现已能识别大型考试
This commit is contained in:
parent
c1bbc7fad8
commit
4759c20103
|
|
@ -2732,19 +2732,22 @@ def CheckPaperType(filepath,filename): #根据filepath(通常是小闲的zip解
|
|||
def generateColIndexandMarks(filepath,statsfilename,paperinfo): #根据filepath(是一个有statsfilename的文件夹列表)中第一个路径中的数据文件, statsfilename数据文件名, 及paperinfo(FindPaper返回的结果)寻找excel文件中有效的列的位置和相应的满分分数
|
||||
dir = filepath[0]
|
||||
dfcurrent = pd.read_excel(os.path.join(dir,statsfilename))
|
||||
validcols = []
|
||||
excludecols = []
|
||||
for i in range(len(dfcurrent.columns)):
|
||||
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) == []:
|
||||
validcols.append(i)
|
||||
for col in range(len(validcols)-1,-1,-1):
|
||||
colname = str(dfcurrent.iloc[1,validcols[col]])
|
||||
if "主观" in colname:
|
||||
colname_main = re.findall(r"^([\d\.]*)[\($]",colname[2:])[0]
|
||||
t = [dfcurrent.iloc[1,c] for c in validcols[col+1:]]
|
||||
t = str(t)
|
||||
if colname_main in t:
|
||||
validcols.pop(col)
|
||||
if re.findall("[A-Z]",colname) != []:
|
||||
excludecols.append(i)
|
||||
validcoldict = {}
|
||||
for i in range(len(dfcurrent.columns)):
|
||||
colname = str(dfcurrent.iloc[1,i])
|
||||
digname = re.findall(r"[\d\.]+",colname)
|
||||
if len(digname) > 0 and not i in excludecols:
|
||||
if not i-1 in validcoldict or not validcoldict[i-1] in digname[0]:
|
||||
validcoldict[i] = digname[0]
|
||||
else:
|
||||
validcoldict.pop(i-1)
|
||||
validcoldict[i] = digname[0]
|
||||
validcols = list(validcoldict.keys())
|
||||
if paperinfo[3] == []:
|
||||
marks = [1] * len(validcols)
|
||||
else:
|
||||
|
|
|
|||
Reference in New Issue