提交 0973e8fa 编写于 作者: 张志晨

add train blink data

上级 1bba778d
......@@ -12,4 +12,7 @@ test.cpp
test.py
test.java
tree_algorithm_view.xlsx
tree_gml_view.xlsx
\ No newline at end of file
tree_gml_view.xlsx
test.html
blink_chengxurensheng.json
it_knowledge_helper.py
......@@ -4,6 +4,7 @@ import sys
import uuid
import json
import shutil
import markdown
from collections import Counter
......@@ -284,5 +285,75 @@ def update_it_konwledge():
def add_it_konwledge_for_blink_comment():
blink_it_map = {
"程序人生" : []
}
save_path = "./blink_chengxurensheng.json"
data_dir = 'data_source/it_knowledge'
it_mapping_path = 'data_source/it_mapping.json'
it_mapping = load_json(it_mapping_path)
exist_files = it_mapping.keys()
files = get_files_path(data_dir, '.md')
language = 'json'
for file in files:
with open(file, 'r', encoding='utf-8') as f:
data = f.read()
file_name = file.split('/')[-1].split('.')[0]
question_title = re.findall(r'## 标题\n(.*?)\n##', data, re.S)[0]
question_title = question_title.strip()
question_content = re.findall(r'## 描述\n(.*?)\n##', data, re.S)[0]
question_content = question_content.strip()
keywords = re.findall(r'## 关键词\n(.*?)\n##', data, re.S)[0]
keywords = keywords.strip()
keywords_list = keywords.split(';')
keywords = ','.join(keywords_list)
topic_link = re.findall(r'## 链接\n(.*?)\n##', data, re.S)[0]
topic_link = topic_link.strip()
choice = re.findall(r'## 选项\n(.*?)\n##', data, re.S)[0]
choice_list = choice.split('\n')
choice_list_res = []
for tem in choice_list:
if tem == '':
continue
else:
tem = tem.strip()
choice_list_res.append(tem)
answer = re.findall(r'## 答案\n(.*)', data, re.S)[0]
answer = answer.strip()
assert answer in choice_list_res
assert len(choice_list_res) >= 4
question_id = file_name
choice_list_remove = []
for idx, val in enumerate(choice_list_res):
if val == answer:
answer_idx = idx
continue
else:
choice_list_remove.append(val)
choice_data = "A--" + choice_list_res[0] + "<br>" + "B--" + choice_list_res[1] + "<br>" + "C--" + choice_list_res[2] + "<br>" + "D--" + choice_list_res[3] + "<br>"
print(topic_link)
blink_data = f"{question_content} <br> {choice_data} <br> 猛戳下方链接寻找答案⬇️⬇️⬇️ <br> [{question_title}]({topic_link})"
blink_data = markdown.markdown(blink_data)
blink_it_map["程序人生"].append(blink_data)
dump_json(save_path, blink_it_map)
add_it_konwledge_for_blink_comment()
update_it_konwledge()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册