#!/usr/bin/env/python # -*- coding:utf-8 -*- """ 单题再解析、结构化 """ import re from structure.option import option_structure from utils.equation_extract import get_simpstr2eqn, get_equation_instr from utils.html_again_parse import css_label_wash from utils.washutil import base642img, css_conflict_deal, convert_huanhang from utils.field_eq2latex import latex_wash from structure.dati2slave import get_slave def single_parse(one_item, item_type, wordid): """ rtype:题型 :return: """ # if re.search("选择|不定选择|多选|单选", rtype): # if "【选项】" not in one_item: # return "请不要将本编辑框自带的“【选项】、【答案】、【解析】”字段删除" # if "【答案】" not in one_item or "【解析】" not in one_item: # return "请不要将本编辑框自带的“【答案】、【解析】”字段删除" print("原始:") # print(one_item) one_item = css_label_wash(one_item) one_item = re.sub("|\s*|\n\s*)+<(/?table( .*?)?|/?tbody( .*?)?|/?t[rhd]( .*?)?)>\s*(\s*|\n\s*)+", r"<\2>", one_item) one_item = re.sub(r'(||)(|\n)+', r"\1", one_item, flags=re.S) one_item = re.sub(r"\\\(\s*{\s*\}\s*\\\)", "", one_item) one_item = re.sub(r"\\\(\s*\\\)", "", one_item) one_item = re.sub(r"\\\(|\\\)", "$", one_item) one_item = latex_wash(one_item, 1) res_list = re.split(r"(\n+【答案】|\n+【解析】)", one_item) if len(res_list) > 5: return "编辑后的文本出现多个【答案】或【解析】字段,请删除,每个字段只保留唯一且单独成行" elif len(res_list) < 5: res_list = re.split(r"(【答案】|【解析】)", one_item) if len(res_list) > 5: return "编辑后的文本出现多个【答案】或【解析】字段,请删除,每个字段只保留唯一且单独成行" # elif len(res_list) < 5: # return "编辑后的文本掉了【答案】或【解析】字段,请添加,每个字段保留唯一" new_item_struct = {} new_item_struct["key"] = "" new_item_struct["parse"] = "" new_item_struct["stem"] = res_list[0] if len(res_list) == 5: if res_list[1].strip() == "【答案】" and res_list[3].strip() == "【解析】": new_item_struct["key"] = res_list[2] new_item_struct["parse"] = res_list[4] elif res_list[1].strip() == "【解析】" and res_list[3].strip() == "【答案】": new_item_struct["key"] = res_list[4] new_item_struct["parse"] = res_list[2] else: return "编辑后的文本出现多个【答案】或【解析】字段,请修改,每个字段只保留唯一且单独成行" elif len(res_list) > 2: if res_list[1].strip() == "【答案】": new_item_struct["key"] = res_list[2] elif res_list[1].strip() == "【解析】": new_item_struct["parse"] = res_list[2] item_ids = re.findall("^([1-9][0-9]|[1-9])\s*[..、、]", new_item_struct["stem"].strip()) new_item_struct["topic_num"] = int(item_ids[0]) if item_ids else 0 new_item_struct["stem"] = re.sub("^([1-9][0-9]|[1-9])\s*[..、、]", "", new_item_struct["stem"].strip()) if len(new_item_struct["stem"].strip()) < 3: return "题干为空,请补充完整" # 选项再解析 new_item_struct["errmsgs"] = [] if re.search("选择|不定选择|多选|单选", item_type): new_item_struct = option_structure(new_item_struct, new_item_struct["stem"], new_item_struct["key"], 1, 1) if new_item_struct["errmsgs"]: return ";;".join(new_item_struct["errmsgs"]) if 'options' in new_item_struct and any([True for i in new_item_struct['options'] if not i.replace(":", "").strip()]): # 空选项中:被当成了内容 return "存在选项为空,请补充完整" new_item_struct["answer_type"] = "选择题" else: new_item_struct["type"] = item_type new_item_struct = get_slave(new_item_struct, new_item_struct["stem"], new_item_struct["parse"], new_item_struct["key"]) if "item_id" in new_item_struct: del new_item_struct["item_id"] # 换行符替换 convert_huanhang(new_item_struct) # new_item_struct["stem"] = new_item_struct["stem"].strip().replace("\n\n", "\n").replace("\n", "
") # 2020/4/10 gai # new_item_struct["key"] = new_item_struct["key"].strip().replace("\n\n", "\n").replace("\n", "
") # new_item_struct["parse"] = new_item_struct["parse"].strip().replace("\n\n", "\n").replace("\n", "
") # if "options" in new_item_struct: # 对选项部分进行格式处理 get_equation_instr # for i in range(len(new_item_struct['options'])): # new_item_struct['options'][i] = new_item_struct['options'][i].strip().replace("\n\n", "\n")\ # .replace("\n", "
") new_item_struct["errmsgs"] = ";".join(new_item_struct["errmsgs"]) # print(new_item_struct) return new_item_struct if __name__ == '__main__': from pprint import pprint html = r'''
11.在2A(g)+B(g)3C(g)+4D(g)反应中,表示该反应速率最快的是

A、v(A)=8mol·L-1·min-1
B、v(B)=0.3mol·L-1·s-1
C、v(C)=0.6mol·L-1·s-1
D、v(D)=1mol·L-1·s-1
  •  
【答案】B
【解析】都换算成用B表示的速率,分别为:
A.v(B)=\(\frac{\text{8mol}\cdot {\text{L}}^{\text{-1}}·{\text{min}}^{\text{-1}}}{\text{2}×\text{60s}\cdot {\text{min}}^{\text{-1}}}\)=0.067 mol·L-1·s-1
B.v(B)=0.3mol·L-1·s-1
C.v(B)=\(\frac{\text{0}\text{.6mol}·{\text{L}}^{\text{-1}}·{\text{s}}^{\text{-1}}}{\text{3}}\)=0.2mol·L-1·s-1
D.v(B)=\(\frac{\text{1mol}·{\text{L}}^{\text{-1}}·{\text{s}}^{\text{-1}}}{\text{4}}\)=0.25mol·L-1·s-1;所以B选项最快,故选B。
【点睛】
比较用不同物质表示的反应速率快慢时,根据速率之比等于方程式的化学计量数之比,换算成用同一种物质表示的速率,同时还要注意单位的统一。
''' hml2 = """
7.农业生产中的一些栽培措施可以影响作物的生理活动,促进作物的生长发育,达到增加产量等目的。回答下列问题:
(1)中耕松土、科学施肥、合理灌溉等措施都能有效提高农作物的产量。中耕是指作物生长期中,在植株之间去除杂草并进行松土的一项栽培措施,该栽培措施对作物的作用有____________(答出1点即可)。农田施肥的同时,往往需要适当浇水,此时浇水的原因是____________________(答出1点即可)。
【答案】(1)减少杂草对水分、矿质元素和光的竞争增加土壤氧气含量,促进根系的呼吸作用 肥料中的矿质元素只有溶解在水中才能被作物根系吸收 (2)叶绿体类囊体薄膜 C5 叶绿体基质 (3)A和D 作物A光饱和点高且长得高,可利用上层光照进行光合作用;作物D光饱和点低且长得矮,与作物A间作后,能利用下层弱光进行光合作用
【解析】(1)去除杂草减小种间竞争,使作物有更多的营养物质并得到更多的光照,进行松土可以减少杂草对水分、矿质元素和光的竞争增加土壤氧气含量,促进根系的呼吸作用。农田施肥浇水可以降低肥料浓度,避免肥料浓度高导致植物失水过多,影响正常生长,另外肥料中的矿质元素只有溶解在水中才能被作物根系吸收。(2)在农作物叶肉细胞中,光合色素分布在叶绿体类囊体薄膜上;参与CO2固定的化学物质是C5,C5和CO2生成C3,为暗反应过程的酶在叶绿体基质中。(3)从提高光能利用率的角度考虑,种间套作一般高矮植株套作,高的植物对光能要求高,矮的植株对光能要求低。表中分析可得,作物A光饱和点高且长得高,可利用上层光照进行光合作用;作物D光饱和点低且长得矮,与作物A间作后,能利用下层弱光进行光合作用,故最适合进行间作的两种作物是A和D。
""" hml3="""
20.如图所示,竖直放置、导热良好的\(U\)形管内装有水银,右管封闭了一段长L=20cn
的空气柱,此时左、右两侧的水银面高度差为\({h_{1}=13cm}\)现从管的开口端慢慢倒入水银,最
终左管水银面比右管水银面高\({h_{2}=8\quad cm}\),环境温度始终不变,外界大气压po=
\({76cmHg_{\circ }}\)求:
(1)右管封闭空气柱的最终长度,
(2)加入的水银柱长度,
衡中]
同卷
【答案】B
【解析】15.解:(1)以封闭气体为研究对象,初态
\({j_{1}=b_{0}-ogh_{1}=63\quad cmHg,V_{1}=L}\)
末态
\({f_{2}=p_{0}+ogh_{2}=84cmg,V_{2}=L^{\prime },}\)
根据玻意耳定律
\({p_{1}V_{1}=p_{2}V_{2}}\)
解得\({L^{\prime }=15cm}\)
(2)右管中水银柱增加的长度
\({x_{1}=L-L^{\prime }=5\cot1}\)
左管中水银柱增加的长度
\({r_{2}=h_{1}+h_{2}+(L-L^{\prime })=26c}\)
加入的水银柱长度
\({x=x_{1}+x_{2}=31cm}\)
""" hml4 = """
5.解磷菌是土壤中的一类功能微生物,包括细菌、真菌和放线菌。筛选出土壤中的高效解磷菌并制成生物菌剂,可以提高难溶性磷的利用率。下表为“分离出土壤中具有解磷功能的微生物实验”的培养基配方,下列说法正确的是( )
物质 葡萄糖 (NH4)2SO4 NaCl KCl CaCO3 磷酸三钙 琼脂
质量/g 10 0.5 3 0.3 5 20 15

A:
培养基中加入琼脂的目的是作为凝固剂和提供碳源
  • B:该培养基是以磷酸三钙为唯一磷源的选择培养基
  • C:用平板划线法纯化解磷菌可以计数其活菌的数量
  • D:可根据培养基中透明圈的大小确定菌株的解磷能力
【答案】B
【解析】【分析】1、微生物常见的接种的方法:(1)平板划线法:将已经熔化的培养基倒入培养皿制成平板,接种、划线,在恒温箱里培养,在线的开始部分,微生物往往连在一起生长,随着线的延伸,菌数逐渐减少,最后可能形成单个菌落。(2)稀释涂布平板法:将待分离的菌液经过大量稀释后,均匀涂布在培养皿表面,经培养后可形成单个菌落。
2、选择培养基:根据某种微生物的特殊营养要求或其对某化学、物理因素的抗性而设计的培养基使混合菌样中的劣势菌变成优势菌,从而提高该菌的筛选率,如加入青霉素分离得到酵母菌和霉菌。
【详解】A、配制固体培养基时可加入琼脂作为凝固剂,琼脂一般不会被微生物所利用,A错误;
B、本实验的目的是获得具有解磷功能的微生物,故其选择培养基中应以磷酸三钙为唯一磷源,B正确;
C、用稀释涂布平板法纯化解磷菌可以计数其活菌的数量,C错误;
D、可根据透明圈直径(D)与菌落直径(d)的比值(D/d)代表微生物解磷能力大小,D错误。
故选B。
""" aa = single_parse(hml4, "选择题", "456") pprint(aa) # tt = r""" # 25℃时,若测得HR溶液$\text{pH=a}$,取该溶液$\text{10}\text{.0mL}$,加蒸馏水稀释至$\text{100}\text{.0mL}$,测得$\text{pH=b,b-a<1}$,则HR是弱酸 # """ # # one_item = base642img(tt, "333333333") # one_item = css_conflict_deal(one_item) # print(one_item)