equation_extract.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. #!/usr/bin/env/python
  2. # -*- coding:utf-8 -*-
  3. """"
  4. 公式提取及整合==>加$$
  5. """
  6. import re
  7. def get_equation_str(item):
  8. """
  9. 1.存在公式字符串与选项一起的情况,此时,先提取选项,再公式比较好
  10. 2.先把题号去掉
  11. 3.对逗号进一步判断是否继续拆
  12. 4.故选:A-F 最好不要划分为公式
  13. :param item:
  14. :return:
  15. """
  16. item = re.sub(r">", '>', str(item))
  17. item = re.sub(r"&lt;", '<', item)
  18. pattern1 = re.compile(
  19. r"([\da-zA-Z!\"'(*+\-\[{|#%\\><≤≥≡≦≧+-≈≠﹢﹣±㏒㏑∑∏><==×÷(△∆⊙⌒∈∩∉∪⊕∥∣≌∽∧⊥∫∬∮∯∅≮≯∁Ω→°•"
  20. r"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨαβγδεζνξοπρσηθικλτυφχψωμGgmst]"
  21. r"([\da-zA-Z!\"&'()*+,,\-../:;?\[\]{}|#%~^_`、、\\><≤≥≡≦≧+-≈≠﹢﹣±㏒㏑∑∏><==×÷()△∆⊙⌒∈∩∉∪⊕∥∣≌∽∧⊥∫∬∮∯∅≮≯∁Ω→°•′~·"
  22. r"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨαβγδεζνξοπρσηθικλτυφχψωμGgmst/∶∝]"
  23. r"|\s|\n)+)")
  24. pattern2 = re.compile("([!\"&'()*+,,\-../:;?\[\]{}|#%~^_`、、]|\s|\n)")
  25. if re.search("<sub>\s*[\u4e00-\u9fa5][\u4e00-\u9fa5、、\s]*?</sub>|\\text\s*{\s*[\u4e00-\u9fa5][\u4e00-\u9fa5、、\s]*?\}", str(item)):
  26. pattern1 = re.compile(
  27. r"([\da-zA-Z!\"'(*+\-\[{|#%\\><≤≥≡≦≧+-≈≠﹢﹣±㏒㏑∑∏><==×÷(△∆⊙⌒∈∩∉∪⊕∥∣≌∽∧⊥∫∬∮∯∅≮≯∁Ω→°•"
  28. r"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨαβγδεζνξοπρσηθικλτυφχψωμGgmst]"
  29. r"(<sub>\s*[\u4e00-\u9fa5][\u4e00-\u9fa5、、\s]*?</sub>" # add
  30. r"|[\da-zA-Z!\"&'()*+,,\-../:;?\[\]{}|#%~^_`、、\\><≤≥≡≦≧+-≈≠﹢﹣±㏒㏑∑∏><==×÷()△∆⊙⌒∈∩∉∪⊕∥∣≌∽∧⊥∫∬∮∯∅≮≯∁Ω→°•′~·"
  31. r"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨαβγδεζνξοπρσηθικλτυφχψωμGgmst/∶∝]"
  32. r"|\s|\n)+)")
  33. all_equa = [y[0] for y in re.findall(pattern1, str(item))]
  34. print("all_equa:", all_equa)
  35. right_equa = []
  36. for i in all_equa:
  37. if re.sub(pattern2, "", i):
  38. i = re.sub("^([1-9]|[1-5][0-9])\s*[、、]|^([1-9]|[1-5][0-9])\s*[..]$|^[))]?\s*[((][\s\d]+[))]", "", i)
  39. i = re.sub("^([1-9]|[1-5][0-9])\s*[、、..]\s*([((]\d*)?$", "", i)
  40. i = re.sub("^([1-9]|[1-5][0-9])\s*[、、..]\s*[((][\s\d]+[))]", "", i)
  41. i = re.sub("[(\[{、、..,,(∶]+$", "", i)
  42. i = re.sub("^https?://.+?$|^www\..+?$", "", i)
  43. i = re.sub("^[))]?\s*[((][\s\w]*[))]", "", i)
  44. i = re.sub("^\d+[))]|^[((]\d+$", "", i)
  45. i = re.sub("(\u3000)+\s*$|^\s*(\u3000)+", "", i)
  46. i = re.sub("\u3000", " ", i)
  47. i = re.sub(r"^\s*([1-9]|[1-5][0-9])\s*[..、、]\s*[A-Z]{1,3}\s*$", "", i)
  48. i = re.sub(r"^\s*([1-9]|[1-5][0-9])\s*[..、、]\s*([^\d])", r"\2", i)
  49. i = re.sub(r"^\s*[a-z][--][a-z]\s*$", '', i)
  50. i = re.sub(r"^\s*<[a-z]+/?>\s*$", '', i)
  51. i = re.sub(r"^([^((]+?)[))]$|^([^{]+?)\}$|^([^\[]+?)\]$", r'\1', i)
  52. i = re.sub(r"^[((]([^))]+?$)|^{([^\}]+?$)|^\[([^\]]+?$)", r'\1', i)
  53. def deal(yy):
  54. return yy.group(1).replace(",", "、").replace(",", "、")
  55. i = re.sub(r"^(([A-Z]\s*[,,])+[A-Z])$", deal, i)
  56. i = re.sub(r"^(\d+|\d+·\d+)$", "", i)
  57. i = re.sub(r"^[A-E]\s*[、、..,,]\s*[A-Za-z\d]$", "", i)
  58. i = re.sub(r"[,,]\s*[A-F]$", "", i)
  59. i = i.replace("G", "G").replace("g", "g").replace("m", "m").replace("s", "s").replace("/", "/").replace("=", "=")\
  60. .replace("2", "2").replace("F", "F").replace("t", "t").strip()
  61. if len(i) > 1:
  62. right_equa.append(i)
  63. return right_equa
  64. def get_equation_instr(item):
  65. """
  66. 先结构化,再提取公式渲染比较好!!!# 公式字符串提取再补上$$
  67. :param item:
  68. :return:
  69. """
  70. # print('///////////////原始:', item)
  71. item = item.replace("(", "(").replace(")", ")")
  72. item = re.sub(r"图(\d{1,2}[--]\d{1,2})", "图&#&"+r"\1", item)
  73. item = re.sub(r"&gt;", '>', str(item))
  74. item = re.sub(r"&lt;", '<', item)
  75. item = re.sub(r"\\lt br/?>", '<br/>', item)
  76. item = re.sub(r"\s{2,}(</su[bp]>)", r'\1', item)
  77. item = re.sub(r"(<su[bp]>)\s{2,}", r'\1', item)
  78. # pattern1 = re.compile(r"<sub>\s*[\u4e00-\u9fa5][\u4e00-\u9fa5、、\s]*?</sub>|\\text\s*{\s*[\u4e00-\u9fa5][\u4e00-\u9fa5、、\s]*?\}")
  79. pattern1 = re.compile("([^\u4e00-\u9fa5;,、:①②③④\s”《》【】“))\]\}](<su[bp]>\s*[\u4e00-\u9fa5][\u4e00-\u9fa5、、\s]*?</su[bp]>"
  80. "|\\text\s*{\s*[\u4e00-\u9fa5][\u4e00-\u9fa5、、\s]*?\}|[_^{]\s*[\u4e00-\u9fa5][\u4e00-\u9fa5、、\s]*?"
  81. "|[^\u4e00-\u9fa5;“”。?①②③④]|\n)*)") # 不以xxx开头,不包含xxx
  82. all_equa = [y[0] for y in re.findall(pattern1, str(item))]
  83. # -------------按某些格式(如图片)将初步提取的公式进一步拆分-------------------
  84. new_all_equa = []
  85. for equa in all_equa:
  86. table_equa = re.findall("<td>(.*?)</td>", equa) # 表格内的公式
  87. if table_equa:
  88. for ta in table_equa: # 不包含图片,data-latex中肯定含有$
  89. new_all_equa.extend([e for e in re.split(r'<img src=[^$]*?/?>|<img src=.*? data-latex="\$\s*\$".*?/?>', ta) if e])
  90. else:
  91. equa = re.split(r'<img src=[^$]*?/?>|<img src=.*? data-latex="\$\s*\$".*?/?>|\.{7,}|=__{2,}' #
  92. r'|<br\s*/?>\s*[((]?\s*[1-9]\s*[))]\s*(?![+\-*/])|\s{2,}(?![+\-*/])|[((]\s*[123456]\s*[))]', equa) # ①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳
  93. new_all_equa.extend([e for e in equa if e])
  94. print("初步提取new_all_equa:", all_equa)
  95. # --------------将需要更改的公式提取出来,映射----------------------------------
  96. right_equa = {}
  97. for i in new_all_equa:
  98. raw_eqn = i
  99. i = re.sub(r'<img src=.+? data-latex="\$(.+?)\$"\s*/?>', "", i)
  100. # 只是img公式的,不需要
  101. if not re.sub("[((]\s*\d{1,2}\s*[))]|[${}()()。①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳【】]"
  102. "|</?t[hdr]>|<br\s*/?>|</?table>|</?html>|</?t?body>|</?p>", "", i).strip():
  103. continue
  104. # 简单公式,清洗一下
  105. # if re.match(r"\d{1,4}[.,;]*$|[A-Z]{1,2}[.,;]*$|[a-z]{1,2}[.,;]*$|(\\rm|\\mathrm)\s*[A-Z]{1,3}[\s.,;]*$"
  106. # r"|(\\rm|\\mathrm)\s*[A-Z][\s.,;]*[A-Z][\s.,;]*$|[A-G]\s*[、,,]\s*[A-G]$|[()\[\]{}\s\\,;.!…\d]+$",
  107. # re.sub("[${}()()]", "", i).strip()):
  108. # # i = re.sub(r"[${}]|\\rm|\\mathrm", "", raw_eqn).strip()
  109. # # i = re.sub(r"\\,", " ", i)
  110. # # if i != raw_eqn.strip():
  111. # # item = item.replace(raw_eqn, i, 1)
  112. # right_equa[raw_eqn] = "${}$".format(i)
  113. # print("{}----变1----${}$".format(raw_eqn, i))
  114. # else:
  115. pattern2 = re.compile("([!\"“”&'()()*+,,\-..。/::;?\[\]{}|#%~^_`、、]|\s|\n|\u3000)")
  116. if re.sub(pattern2, "", i):
  117. i = re.sub(r'<img src=.+? data-latex="\$(.+?)\$"\s*/?>', r"\1", raw_eqn)
  118. # 结合最开始的替换操作
  119. i = re.sub(r"^&#&.+?$", "", i)
  120. i = re.sub(r"^\.+", "", i)
  121. i = re.sub("^([!&),,..::;。?\]}#%、、]|\s|\n)", "", i)
  122. i = re.sub("^([1-9]|[1-5][0-9])\s*[、、]|^([1-9]|[1-5][0-9])\s*[..]$|^[))]?\s*[((][\s\d]+[))]", "", i)
  123. i = re.sub("^([1-9]|[1-5][0-9])\s*[、、..]\s*([((]\d*)?$", "", i)
  124. i = re.sub("^([1-9]|[1-5][0-9])\s*[、、..]\s*[((][\s\d]+[))]", "", i)
  125. i = re.sub("^https?://.+?$|^www\..+?$", "", i)
  126. i = re.sub("^[))]?\s*[((][\s\w]*[))]", "", i)
  127. i = re.sub("^([^((]*?)[))]", r"\1", i)
  128. i = re.sub("^\d+[))]|^[((]\d+$", "", i)
  129. i = re.sub("(\u3000)+\s*$|^\s*(\u3000)+", "", i)
  130. i = re.sub(r"^\s*([1-9]|[1-5][0-9])\s*[..、、]\s*[A-Z]{1,3}\s*$", "", i)
  131. i = re.sub(r"^\s*([1-9]|[1-5][0-9])\s*[..、、]\s*([^\d])", r"\2", i)
  132. # i = re.sub(r"^\s*[a-z][--][a-z]\s*$", '', i) # 'v-t', 'x-t'
  133. i = re.sub(r"^\s*\d{1,2}[--]\d{1,2}\s*$", '', i)
  134. i = re.sub(r"^\s*<[a-z]+/?>\s*$", '', i)
  135. i = re.sub(r"^([^((]+?)[))]$|^([^{]+?)\}$|^([^\[]+?)\]$", r'\1\2\3', i)
  136. i = re.sub(r"^[((]([^))]+?$)|^{([^\}]+?$)|^\[([^\]]+?$)", r'\1\2\3', i)
  137. i = re.sub(r"[,,]\s*[A-F]$", "", i)
  138. i = re.sub(r"[(\[{、、..,,(∶”?】【]+$|(<br\s*/?>)+$", "", i)
  139. i = re.sub(r"=[\s_]*?$", "", i)
  140. i = re.sub(r"^__[\s_]*?([^\s_]+?)$", r"\1", i)
  141. i = re.sub(r"(<br\s*/?>|\n)+?\s*$|^\s*(<br\s*/?>|\n)+?", "", i)
  142. i = re.sub("^[①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳]*?([^①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳]+?)"
  143. "[①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳]*?$", r"\1", i.strip())
  144. raw_eqn = i
  145. i = re.sub("\u3000", " ", i)
  146. # def deal(yy):
  147. # return yy.group(1).replace(",", "、").replace(",", "、")
  148. # i = re.sub(r"^(([A-Z]\s*[,,])+[A-Z])$", deal, i)
  149. # # 不渲染
  150. # i = re.sub(r"^(([A-Z]\s*[,,、、])+[A-Z])$", "", i) # A、B、C、D 不渲染
  151. # i = re.sub(r"^[A-Za-z]{2}$", "", i) # 不渲染
  152. # i = re.sub(r"^(\d+|\d+·\d+)$", "", i)
  153. # i = re.sub(r"^[A-E]\s*[、、..,,]\s*[A-Za-z\d]$", "", i)
  154. sub_dd = {
  155. "F": "F",
  156. "G": "G",
  157. "g": "g",
  158. "m": "m",
  159. "N": "N",
  160. "s": "s",
  161. "t": "t",
  162. "/": "/",
  163. "=": "=",
  164. "-": "-",
  165. "2": "2",
  166. "′": "'",
  167. # "°": "^\ciro", # \\cir后面可以随便加字母或数字
  168. }
  169. i = re.sub("|".join(sub_dd.keys()), lambda x: sub_dd[x.group()], i)
  170. # i = i.replace("G", "G").replace("g", "g").replace("m", "m").replace("s", "s").replace("/", "/").replace("=", "=") \
  171. # .replace("2", "2").replace("F", "F").replace("t", "t").replace("N","N").replace("-", "-").strip()
  172. # 个别不符latex格式的公式 处理
  173. def deal2(yy):
  174. new_y = yy.group(2)
  175. if yy.group(1) == "<sub>":
  176. new_y = "_{" + yy.group(2) + "}"
  177. if yy.group(1) == "<sup>":
  178. new_y = "^{" + yy.group(2) + "}"
  179. return re.sub("([\u4e00-\u9fa5]+)", r"\\text{\1}", new_y)
  180. # i = re.sub("(<sub>)(.+?)</sub>", deal2, i)
  181. # i = re.sub("(<sup>)(.+?)</sup>", deal2, i).strip()
  182. recur_n = 0
  183. while re.search(r"</?su[bp]>", i):
  184. recur_n += 1
  185. i = re.sub("(<sub>)(((?!</?sub>).)+?)</sub>", deal2, i)
  186. i = re.sub("(<sup>)(((?!</?sup>).)+?)</sup>", deal2, i)
  187. if recur_n > 5:
  188. break
  189. i = re.sub(r"\^{(.*?)\}\^{(.*?)\}", r"^{\1^{\2}}", i)
  190. if len(i) > 0: # 单个字母或数字也渲染
  191. new_eq = re.sub("^\$(\s+)(.+?)(?<!\s)\$$", r"\1$\2$", "${}$".format(i.replace("$", "")))
  192. new_eq = re.sub("^\$(?!\s)(.+?)(\s+)\$", r"$\1$\2", new_eq)
  193. right_equa[raw_eqn] = new_eq
  194. # item = item.replace(raw_eqn, "${}$".format(i), 1)
  195. print("{}----变2----${}$".format(raw_eqn, new_eq))
  196. right_equa = sorted(right_equa.items(), key=lambda x: len(x[1]), reverse=True)
  197. print("提取的公式整合、清洗->right_equa:",right_equa)
  198. # 图片替换
  199. all_image = re.findall(r'<img src=".*?image[\da-z]+\..*?[/\"]>', item)
  200. subs2src = {}
  201. for j, img in enumerate(all_image):
  202. item = item.replace(img, "【&img{}&】".format(j))
  203. subs2src["【&img{}&】".format(j)] = img
  204. temp_map = {}
  205. for n, eq in enumerate(right_equa):
  206. if eq[0] not in ["e1", "e2","e3", "e4", "e5", "e6", "e7", "e8", "e9"]:
  207. if eq[0] not in "http://zxhx-1302712961.cos.ap-shanghai.myqcloud.com/zyk/uploadfiles/wording/new_image59.png"\
  208. or len(eq[0]) < 3:
  209. if re.search("^(\d+|[img]+)$", eq[0]) is None:
  210. item = item.replace(eq[0], "#&{}&#".format(n))
  211. # else:
  212. # item = re.sub("(?<!#&)" + eq[0], "#&{}&#".format(n), item)
  213. # item = re.sub(r"(#&.+?&#)", lambda x: x.group(1).replace("$", ""), item) # 无效
  214. temp_map["#&{}&#".format(n)] = eq[1]
  215. # print("temp_map:", temp_map)
  216. for k, v in subs2src.items():
  217. item = item.replace(k, v)
  218. for k, v in temp_map.items():
  219. item = re.sub(r"#&.+?&#", lambda x: x.group().replace("$", ""), item)
  220. item = item.replace(k, v)
  221. for k, v in temp_map.items():
  222. # item = re.sub(r"#&.+?&#", lambda x: x.group().replace("$", ""), item)
  223. item = item.replace(k, v)
  224. # print("res:", item)
  225. return item
  226. def get_simpstr2eqn(item):
  227. "将简单的数字转为公式,加$"
  228. item = re.sub(r"^\n*([\dA-Za-z][A-Za-z\d\s]*)(\n*)$", r"$\1\2$", item)
  229. # item = re.sub(r"([\u4e00-\u9fa5]\s*|<img.*?/>\s*|^\n*)([\dA-Za-z][A-Za-z\d\s]*)([\u4e00-\u9fa5]|<img|\n*$)",
  230. # r"\1$\2$\3", item)
  231. return item
  232. if __name__ == '__main__':
  233. # import pandas as pd
  234. # from formula_extract_lqy2 import formula_extract_lqy
  235. #
  236. # pp = r"F:\zwj\WL\phy\wordbin2.0\data\WL_train.xlsx"
  237. # df = pd.read_excel(pp)
  238. # df['equations'] = df['item'].apply(get_equation_str)
  239. # df['equations2'] = df['item'].apply(get_equation_str2)
  240. # df['equations3'] = df['item'].apply(formula_extract_lqy)
  241. # flag = []
  242. # new_flag = []
  243. # for index, row in df.iterrows():
  244. # # print(row['equations2'])
  245. # # print(row['equations'])
  246. # # print(len(row['equations2']), len(row['equations']))
  247. # # print("".join(row['equations2']) == "".join(row['equations']))
  248. # # print('===========================')
  249. # if row['equations2'] == row['equations']:
  250. # flag.append(1)
  251. # else:
  252. # flag.append(0)
  253. # if row['equations3'] == row['equations']:
  254. # new_flag.append(1)
  255. # else:
  256. # new_flag.append(0)
  257. # df['flag'] = flag
  258. # df['new_flag'] = new_flag
  259. # df.to_excel(r"F:\zwj\WL\phy\wordbin2.0\data\WL_train4.xlsx")
  260. tt1 = """
  261. 下列物质与危险化学品标志的对应关系不正确的是<br/><table><tr><td>A</td><td>B</td><td>C</td><td>D</td></tr><tr><td>汽油</td><td>天然气</td><td>浓硫酸</td><td>氢氧化钠</td></tr><tr><td><img src="files/image2.png" width="125px" height="116px" /></td><td><img src="files/image3.png" width="117px" height="117px" /></td><td><img src="files/image4.png" width="118px" height="119px" /></td><td><img src="files/image5.png" width="122px" height="118px" /></td></tr></table>
  262. """
  263. tt2 = 'Ag<sup>+</sup>、K<sup>+</sup>、NO<img src="files/image6.png" width="11px" height="25px" data-latex="$$" />、C1<sup>-</sup>'
  264. tt3 = 'Mg<sup>2</sup><sup>+</sup>、Na<sup>+</sup>、Cl<sup>-</sup>、SO<img src="files/image7.png" width="16px" height="24px" data-latex="$$" />'
  265. tt4 = 'NH<img src="files/image8.png" width="11px" height="24px" data-latex="$$" />、Cu<sup>2</sup><sup>+</sup>、OH<sup>一</sup>、Cl<sup>—</sup>'
  266. tt5 = 'H<sup>+</sup>、Na<sup>+</sup>、HCO<img src="files/image9.png" width="11px" height="25px" data-latex="$$" />、SO<img src="files/image10.png" width="16px" height="24px" data-latex="$$" />'
  267. tt6 = '向MgSO<sub>4</sub>和Al<sub>2</sub>(SO<sub>4</sub>)<sub>3</sub>的混合溶液中,逐滴加入NaOH溶液。下列图像中, 能正确表示上述反应的是(横坐标表示加入NaOH溶液的体积,纵坐标表示反应生成沉淀的质量) ( )<br/>【未识别图片】'
  268. tt7 = '把一定量铁粉放入氯化铁溶液中,完全反应后,所得溶液中Fe<img src="files/image11.png" width="7px" height="20px" /><img src="files/image12.png" width="7px" height="20px" />和Fe<img src="files/image13.png" width="7px" height="20px" /><img src="files/image12.png" width="7px" height="20px" />的浓度恰好相等.则已反应的Fe<img src="files/image13.png" width="7px" height="20px" /><img src="files/image12.png" width="7px" height="20px" />和未反应的Fe<img src="files/image13.png" width="7px" height="20px" /><img src="files/image12.png" width="7px" height="20px" />的物质的量之比为( )'
  269. tt8 = '下列物质中既能跟稀H<sub>2</sub>SO<sub>4</sub>反应,又能跟氢氧化钠溶液反应的是( )。<br/>①NaHCO<sub>3 </sub>②Al<sub>2</sub>O<sub>3 </sub>③Al(OH)<sub>3 </sub> ④Al'
  270. tt9 = 'M<sub>2</sub>O <sub>7</sub> <sup>x-</sup>与S<sup>2-</sup> 在酸性溶液中发生如下反应:M<sub>2</sub>O<sub>7</sub><sup>x</sup><sup>-</sup>+3S<sup>2</sup><sup>-</sup>+14H<sup>+</sup>=2M<sup>3+</sup>+3S↓+7H<sub>2</sub>O<br/>则M<sub>2</sub>O<sub>7</sub><sup>x</sup><sup>-</sup> 中M 的化合价为( )'
  271. tt10 = 'AlCl<sub>3</sub>溶液中加入足量的氨水:Al<img src="files/image13.png" width="7px" height="20px" /><img src="files/image12.png" width="7px" height="20px" />+3OH<img src="files/image15.png" width="11px" height="20px" />═Al(OH)<sub>3</sub>↓'
  272. tt11 = 'FeCl<sub>2</sub>溶液跟Cl<sub>2</sub>反应:Fe<sup>2+</sup>+Cl<sub>2</sub>=Fe<sup>3+</sup>+2Cl<sup>-</sup>'
  273. tt12 = '实验室中需要配制2 mol/L的NaCl溶液950 mL,配制时应选用的容量瓶的规格和称取的NaCl的质量分别是( )'
  274. tt13 = '现有下列10种物质:①H<sub>2</sub>O ②空气 ③Al ④明矾 ⑤H<sub>2</sub>SO<sub>4</sub> ⑥烧碱 ⑦CuSO<sub>4</sub>•5H<sub>2</sub>O ⑧碘酒 ⑨C<sub>2</sub>H<sub>5</sub>OH ⑩ 纯碱(1)属于碱的是 ;属于盐的是 ;属于电解质的是 (填写序号)。<br/>(2)④明矾的化学式为 ,向④的溶液中滴加过量⑥溶液反应离子方程式为<br/>(3)⑤的溶液与⑩的溶液反应离子方程式为'
  275. tt14 = '(17分)(1)Fe<sub>2</sub>O<sub>3</sub>+6H<sup>+</sup>═2Fe<sup>3+</sup>+3H<sub>2</sub>O;<br/>(2)NaOH溶液;<br/>(3)Fe+2FeCl<sub>3</sub>═3FeCl<sub>2</sub>;<br/>(4)4Fe(OH)<sub>2</sub>+O<sub>2</sub>+2H<sub>2</sub>O═4Fe(OH)<sub>3</sub>;(5)氢氧化铁胶体 粒子直径大小 生成白色沉淀,迅速变成灰绿色,最终变成红褐色;<br/>1718.17(1)题中通入CO<sub>2</sub>后所得溶液的溶质成分为Na<sub>2</sub>CO<sub>3</sub>和NaHCO<sub>3</sub>,若将所得溶质在低温低压条件下蒸干,所得固体物质(不带结晶水)的质量为13.7g.<br/>(2)原NaOH溶液的物质的量浓度为2mol/L;<br/></body></html>'
  276. p1 = '“天舟一号”是我国首个货运飞船,被大家昵称为“快递小哥”,于2017年4月20发射成功。4月22日“天舟一号”与在轨运行的“天宫二号”空间实验室进行首次交会对接,形成组合体。 要实现“天舟一号”与 “天宫二号”成功对接 ,则'
  277. p2 = '(1)小球p从斜面上下滑的加速度为a,由牛顿第二定律有:<br/><img src="http://zxhx-1302712961.cos.ap-shanghai.myqcloud.com/zyk/uploadfiles/wording/5fc64aca4994183dda7e751b/image59.png" width="93px" height="21px" data-latex="$$"> ..............................................................................................................(2分)<br/>设下滑所需时间为t<sub>1</sub>,根据运动学公式有:<br/><img src="http://zxhx-1302712961.cos.ap-shanghai.myqcloud.com/zyk/uploadfiles/wording/5fc64aca4994183dda7e751b/image60.png" width="52px" height="37px" data-latex="$$"> ..........................................................................................................................(2分)<br/>联立解得:t<sub>1</sub> =0.5 s .........................................................................................................(1分)<br/>(2)小球q做平抛运动,设抛出速度为v<sub>0</sub>,则:<br/><img src="http://zxhx-1302712961.cos.ap-shanghai.myqcloud.com/zyk/uploadfiles/wording/5fc64aca4994183dda7e751b/image61.png" width="46px" height="20px" data-latex="$$">............................................................................................................................(2分)<br/>由几何关系知:x=lcos37° .............................................................................................(1分)<br/>依题意有: t<sub>2</sub>=t<sub>1</sub> .............................................................................................................(1分)<br/>解得: v<sub>0</sub>=1.2<img src="http://zxhx-1302712961.cos.ap-shanghai.myqcloud.com/zyk/uploadfiles/wording/5fc64aca4994183dda7e751b/image62.png" width="34px" height="18px" data-latex="$$"> ...................................................................................................... (1分)'
  278. p3 = '则该金属丝直径的测量值d=___________mm。<br/><img src="http://zxhx-1302712961.cos.ap-shanghai.myqcloud.com/zyk/uploadfiles/wording/6167c1360d2da861d11c950a/image31.png" width="262px" height="146px" /><img src="http://zxhx-1302712961.cos.ap-shanghai.myqcloud.com/zyk/uploadfiles/wording/6167c1360d2da861d11c950a/image32.jpeg" width="162px" height="137px" /><br/>(2)使用多用电表欧姆挡粗测金属丝的电阻,倍率选择“×10”挡,发现指针偏转角度太大了,下列说法不正确的是( )'
  279. p4 = '电流表A(量程为0~0.6 A,内阻约0.5 Ω)'
  280. p5 = '''
  281. 为测定干电池的电动势和内阻,提供的实验器材如下所示:
  282. A.干电池2节,每节干电池的电动势为1.5 V<img src="http://zxhx-1302712961.cos.ap-shanghai.myqcloud.com/zyk/uploadfiles/wording/6167c1360d2da861d11c950a/image34.png" width="26px" height="26px">左右,内阻较小
  283. B.电流表A(量程为0~0.6 A,内阻约0.5 Ω)
  284. C.滑动变阻器R1(0~10 Ω,10 A)D.滑动变阻器R2(0~100 Ω,1 A)
  285. E.电流表G(0~3.0 mA,Rg=10 Ω)F.定值电阻R1=990 Ω
  286. G.定值电阻R2=90 ΩH.开关S和导线若干
  287. (1)由于两节干电池的内阻较小,现将定值电阻R0=3.0 Ω与两节干电池串联后作为一个整体进行测量。在进行实验时,滑动变阻器应选用________,定值电阻应选用________。(填写实验器材前的编号)
  288. (2)在虚线方框中补充完整本实验电路的原理图。
  289. <img src="http://zxhx-1302712961.cos.ap-shanghai.myqcloud.com/zyk/uploadfiles/wording/6167c1360d2da861d11c950a/image35.png" width="382px" height="144px">
  290. (3)根据实验测得数据作出I2-I1的图线如图,其中I2为通过电流表G的电流,I1为通过电流表A的电流.根据该图线可知每节干电池的电动势的测量值为________V,内阻的测量值为________Ω。(结果保留两位有效数字)
  291. '''
  292. p6 = '''
  293. 20.如图所示,xOy平面内半径为R的圆O'与y轴相切于原点O。在该圆形区域内,有与y轴平行的匀强电场和垂直于圆面的匀强磁场。一质量为m、电荷量为q的粒子(不计重力)从O点沿x轴正方向以某一速度射入,带电粒子恰好做匀速直线运动,经T0时间从P点射出。
  294. (1)若仅撤去磁场,带电粒子仍从O点以相同的速度射入,经<img src="http://zxhx-1302712961.cos.ap-shanghai.myqcloud.com/zyk/uploadfiles/wording/6167c1360d2da861d11c950a/image38.png" width="20px" height="37px" data-latex="$$">时间恰从圆形区域的边界射出。求电场强度的大小和粒子离开电场时速度的大小;
  295. (2)若仅撤去电场,带电粒子仍从O点射入,且速度为原来的2倍,求粒子在磁场中运动的时间。
  296. '''
  297. res = get_equation_instr(p6)
  298. print("res:-----------------")
  299. print(res)