提交 95a55df3 编写于 作者: 每日一练社区's avatar 每日一练社区

优化it冷知识处理

上级 31246570
# 不那么正经的图片工厂
# 不那么正经的图片工厂(二)
世界上第一枚微处理器 Intel 4004 在 1971 年正式推出,英特尔反复重启这项芯片的生产计划,以至于它其实一共拥有四个设计者。
......
# 微软的灾难
# 微软的灾难(一)
微软反垄断案又称微软反托拉斯案,是指 1997 年 10 月开始微软涉及的一系列反垄断案件;这起案件导致了微软和 Intel 公开分裂,还使得微软开源了自己的部分技术,让美国司法部打出了“推动创新”的旗号,掀起了第一波 PC 软件产业发展高潮。
......
# 不那么正经的图片工厂
# 不那么正经的图片工厂(一)
免费的图片分享网站 Imgur 创办于2009年,提供了简单直接、带编辑功能的图片在线分享服务,如果 说 Facebook 或者 Flickr 是正规相册、照片的聚集地的话,Imgur 就是类似截图、PS 图以及各种搞笑图的归属之地。
......
# 微软的灾难
# 微软的灾难(二)
TensorFlow 是一个开源软件库,用于各种感知和语言理解任务的机器学习,在 2015 年 11 月 9 日正式发布;TensorFlow 目前被 50 个团队用于研究和生产许多 Google 商业产品,是数学、机器学习和深度学习领域应用最广泛的开源工具之一。
......
## 标题
不那么正经的图片工厂
不那么正经的图片工厂(一)
## 描述
......
## 标题
不那么正经的图片工厂
不那么正经的图片工厂(二)
## 描述
......
## 标题
微软的灾难
微软的灾难(一)
## 描述
......
## 标题
微软的灾难
微软的灾难(二)
## 描述
......
{
"data_backup/it_knowledge/28.md": "data/1.dailycode初阶/4.it_knowledge/1.exercises/solution.md",
"data_backup/it_knowledge/79.md": "data/1.dailycode初阶/4.it_knowledge/2.exercises/solution.md",
"data_backup/it_knowledge/100.md": "data/1.dailycode初阶/4.it_knowledge/3.exercises/solution.md",
"data_backup/it_knowledge/5.md": "data/1.dailycode初阶/4.it_knowledge/4.exercises/solution.md",
"data_backup/it_knowledge/69.md": "data/1.dailycode初阶/4.it_knowledge/5.exercises/solution.md",
"data_backup/it_knowledge/38.md": "data/1.dailycode初阶/4.it_knowledge/6.exercises/solution.md",
"data_backup/it_knowledge/18.md": "data/1.dailycode初阶/4.it_knowledge/7.exercises/solution.md",
"data_backup/it_knowledge/49.md": "data/1.dailycode初阶/4.it_knowledge/8.exercises/solution.md",
"data_backup/it_knowledge/59.md": "data/1.dailycode初阶/4.it_knowledge/9.exercises/solution.md",
"data_backup/it_knowledge/1.md": "data/1.dailycode初阶/4.it_knowledge/10.exercises/solution.md",
"data_backup/it_knowledge/19.md": "data/1.dailycode初阶/4.it_knowledge/11.exercises/solution.md",
"data_backup/it_knowledge/48.md": "data/1.dailycode初阶/4.it_knowledge/12.exercises/solution.md",
"data_backup/it_knowledge/58.md": "data/1.dailycode初阶/4.it_knowledge/13.exercises/solution.md",
"data_backup/it_knowledge/0.md": "data/1.dailycode初阶/4.it_knowledge/14.exercises/solution.md",
"data_backup/it_knowledge/29.md": "data/1.dailycode初阶/4.it_knowledge/15.exercises/solution.md",
"data_backup/it_knowledge/78.md": "data/1.dailycode初阶/4.it_knowledge/16.exercises/solution.md",
"data_backup/it_knowledge/101.md": "data/1.dailycode初阶/4.it_knowledge/17.exercises/solution.md",
"data_backup/it_knowledge/4.md": "data/1.dailycode初阶/4.it_knowledge/18.exercises/solution.md",
"data_backup/it_knowledge/68.md": "data/1.dailycode初阶/4.it_knowledge/19.exercises/solution.md",
"data_backup/it_knowledge/39.md": "data/1.dailycode初阶/4.it_knowledge/20.exercises/solution.md",
"data_backup/it_knowledge/47.md": "data/1.dailycode初阶/4.it_knowledge/21.exercises/solution.md",
"data_backup/it_knowledge/16.md": "data/1.dailycode初阶/4.it_knowledge/22.exercises/solution.md",
"data_backup/it_knowledge/80.md": "data/1.dailycode初阶/4.it_knowledge/23.exercises/solution.md",
"data_backup/it_knowledge/22.md": "data/1.dailycode初阶/4.it_knowledge/24.exercises/solution.md",
"data_backup/it_knowledge/73.md": "data/1.dailycode初阶/4.it_knowledge/25.exercises/solution.md",
"data_backup/it_knowledge/63.md": "data/1.dailycode初阶/4.it_knowledge/26.exercises/solution.md",
"data_backup/it_knowledge/32.md": "data/1.dailycode初阶/4.it_knowledge/27.exercises/solution.md",
"data_backup/it_knowledge/90.md": "data/1.dailycode初阶/4.it_knowledge/28.exercises/solution.md",
"data_backup/it_knowledge/57.md": "data/1.dailycode初阶/4.it_knowledge/29.exercises/solution.md",
"data_backup/it_knowledge/84.md": "data/1.dailycode初阶/4.it_knowledge/30.exercises/solution.md",
"data_backup/it_knowledge/77.md": "data/1.dailycode初阶/4.it_knowledge/31.exercises/solution.md",
"data_backup/it_knowledge/26.md": "data/1.dailycode初阶/4.it_knowledge/32.exercises/solution.md",
"data_backup/it_knowledge/12.md": "data/1.dailycode初阶/4.it_knowledge/33.exercises/solution.md",
"data_backup/it_knowledge/43.md": "data/1.dailycode初阶/4.it_knowledge/34.exercises/solution.md",
"data_backup/it_knowledge/53.md": "data/1.dailycode初阶/4.it_knowledge/35.exercises/solution.md",
"data_backup/it_knowledge/36.md": "data/1.dailycode初阶/4.it_knowledge/36.exercises/solution.md",
"data_backup/it_knowledge/67.md": "data/1.dailycode初阶/4.it_knowledge/37.exercises/solution.md",
"data_backup/it_knowledge/94.md": "data/1.dailycode初阶/4.it_knowledge/38.exercises/solution.md",
"data_backup/it_knowledge/85.md": "data/1.dailycode初阶/4.it_knowledge/39.exercises/solution.md",
"data_backup/it_knowledge/76.md": "data/1.dailycode初阶/4.it_knowledge/40.exercises/solution.md",
"data_backup/it_knowledge/27.md": "data/1.dailycode初阶/4.it_knowledge/41.exercises/solution.md",
"data_backup/it_knowledge/13.md": "data/1.dailycode初阶/4.it_knowledge/42.exercises/solution.md",
"data_backup/it_knowledge/42.md": "data/1.dailycode初阶/4.it_knowledge/43.exercises/solution.md",
"data_backup/it_knowledge/52.md": "data/1.dailycode初阶/4.it_knowledge/44.exercises/solution.md",
"data_backup/it_knowledge/37.md": "data/1.dailycode初阶/4.it_knowledge/45.exercises/solution.md",
"data_backup/it_knowledge/66.md": "data/1.dailycode初阶/4.it_knowledge/46.exercises/solution.md",
"data_backup/it_knowledge/95.md": "data/1.dailycode初阶/4.it_knowledge/47.exercises/solution.md",
"data_backup/it_knowledge/46.md": "data/1.dailycode初阶/4.it_knowledge/48.exercises/solution.md",
"data_backup/it_knowledge/17.md": "data/1.dailycode初阶/4.it_knowledge/49.exercises/solution.md",
"data_backup/it_knowledge/81.md": "data/1.dailycode初阶/4.it_knowledge/50.exercises/solution.md",
"data_backup/it_knowledge/23.md": "data/1.dailycode初阶/4.it_knowledge/51.exercises/solution.md",
"data_backup/it_knowledge/72.md": "data/1.dailycode初阶/4.it_knowledge/52.exercises/solution.md",
"data_backup/it_knowledge/62.md": "data/1.dailycode初阶/4.it_knowledge/53.exercises/solution.md",
"data_backup/it_knowledge/33.md": "data/1.dailycode初阶/4.it_knowledge/54.exercises/solution.md",
"data_backup/it_knowledge/91.md": "data/1.dailycode初阶/4.it_knowledge/55.exercises/solution.md",
"data_backup/it_knowledge/56.md": "data/1.dailycode初阶/4.it_knowledge/56.exercises/solution.md",
"data_backup/it_knowledge/24.md": "data/1.dailycode初阶/4.it_knowledge/57.exercises/solution.md",
"data_backup/it_knowledge/75.md": "data/1.dailycode初阶/4.it_knowledge/58.exercises/solution.md",
"data_backup/it_knowledge/86.md": "data/1.dailycode初阶/4.it_knowledge/59.exercises/solution.md",
"data_backup/it_knowledge/41.md": "data/1.dailycode初阶/4.it_knowledge/60.exercises/solution.md",
"data_backup/it_knowledge/10.md": "data/1.dailycode初阶/4.it_knowledge/61.exercises/solution.md",
"data_backup/it_knowledge/51.md": "data/1.dailycode初阶/4.it_knowledge/62.exercises/solution.md",
"data_backup/it_knowledge/9.md": "data/1.dailycode初阶/4.it_knowledge/63.exercises/solution.md",
"data_backup/it_knowledge/96.md": "data/1.dailycode初阶/4.it_knowledge/64.exercises/solution.md",
"data_backup/it_knowledge/65.md": "data/1.dailycode初阶/4.it_knowledge/65.exercises/solution.md",
"data_backup/it_knowledge/34.md": "data/1.dailycode初阶/4.it_knowledge/66.exercises/solution.md",
"data_backup/it_knowledge/14.md": "data/1.dailycode初阶/4.it_knowledge/67.exercises/solution.md",
"data_backup/it_knowledge/45.md": "data/1.dailycode初阶/4.it_knowledge/68.exercises/solution.md",
"data_backup/it_knowledge/71.md": "data/1.dailycode初阶/4.it_knowledge/69.exercises/solution.md",
"data_backup/it_knowledge/20.md": "data/1.dailycode初阶/4.it_knowledge/70.exercises/solution.md",
"data_backup/it_knowledge/82.md": "data/1.dailycode初阶/4.it_knowledge/71.exercises/solution.md",
"data_backup/it_knowledge/92.md": "data/1.dailycode初阶/4.it_knowledge/72.exercises/solution.md",
"data_backup/it_knowledge/30.md": "data/1.dailycode初阶/4.it_knowledge/73.exercises/solution.md",
"data_backup/it_knowledge/61.md": "data/1.dailycode初阶/4.it_knowledge/74.exercises/solution.md",
"data_backup/it_knowledge/55.md": "data/1.dailycode初阶/4.it_knowledge/75.exercises/solution.md",
"data_backup/it_knowledge/15.md": "data/1.dailycode初阶/4.it_knowledge/76.exercises/solution.md",
"data_backup/it_knowledge/44.md": "data/1.dailycode初阶/4.it_knowledge/77.exercises/solution.md",
"data_backup/it_knowledge/70.md": "data/1.dailycode初阶/4.it_knowledge/78.exercises/solution.md",
"data_backup/it_knowledge/21.md": "data/1.dailycode初阶/4.it_knowledge/79.exercises/solution.md",
"data_backup/it_knowledge/83.md": "data/1.dailycode初阶/4.it_knowledge/80.exercises/solution.md",
"data_backup/it_knowledge/93.md": "data/1.dailycode初阶/4.it_knowledge/81.exercises/solution.md",
"data_backup/it_knowledge/31.md": "data/1.dailycode初阶/4.it_knowledge/82.exercises/solution.md",
"data_backup/it_knowledge/60.md": "data/1.dailycode初阶/4.it_knowledge/83.exercises/solution.md",
"data_backup/it_knowledge/54.md": "data/1.dailycode初阶/4.it_knowledge/84.exercises/solution.md",
"data_backup/it_knowledge/25.md": "data/1.dailycode初阶/4.it_knowledge/85.exercises/solution.md",
"data_backup/it_knowledge/74.md": "data/1.dailycode初阶/4.it_knowledge/86.exercises/solution.md",
"data_backup/it_knowledge/87.md": "data/1.dailycode初阶/4.it_knowledge/87.exercises/solution.md",
"data_backup/it_knowledge/40.md": "data/1.dailycode初阶/4.it_knowledge/88.exercises/solution.md",
"data_backup/it_knowledge/11.md": "data/1.dailycode初阶/4.it_knowledge/89.exercises/solution.md",
"data_backup/it_knowledge/50.md": "data/1.dailycode初阶/4.it_knowledge/90.exercises/solution.md",
"data_backup/it_knowledge/8.md": "data/1.dailycode初阶/4.it_knowledge/91.exercises/solution.md",
"data_backup/it_knowledge/97.md": "data/1.dailycode初阶/4.it_knowledge/92.exercises/solution.md",
"data_backup/it_knowledge/64.md": "data/1.dailycode初阶/4.it_knowledge/93.exercises/solution.md",
"data_backup/it_knowledge/35.md": "data/1.dailycode初阶/4.it_knowledge/94.exercises/solution.md",
"data_backup/it_knowledge/3.md": "data/1.dailycode初阶/4.it_knowledge/95.exercises/solution.md",
"data_backup/it_knowledge/88.md": "data/1.dailycode初阶/4.it_knowledge/96.exercises/solution.md",
"data_backup/it_knowledge/102.md": "data/1.dailycode初阶/4.it_knowledge/97.exercises/solution.md",
"data_backup/it_knowledge/98.md": "data/1.dailycode初阶/4.it_knowledge/98.exercises/solution.md",
"data_backup/it_knowledge/7.md": "data/1.dailycode初阶/4.it_knowledge/99.exercises/solution.md",
"data_backup/it_knowledge/89.md": "data/1.dailycode初阶/4.it_knowledge/100.exercises/solution.md",
"data_backup/it_knowledge/99.md": "data/1.dailycode初阶/4.it_knowledge/101.exercises/solution.md",
"data_backup/it_knowledge/6.md": "data/1.dailycode初阶/4.it_knowledge/102.exercises/solution.md",
"data_backup/it_knowledge/2.md": "data/1.dailycode初阶/4.it_knowledge/103.exercises/solution.md"
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import sys
import uuid
import json
import shutil
from collections import Counter
def get_files_path(file_dir, filetype='.txt'):
......@@ -146,4 +147,93 @@ def extract_it_knowledge():
with open(solution_md_path, 'w', encoding='utf-8') as f:
f.write(solution_md_data)
extract_it_knowledge()
\ No newline at end of file
def get_source_data_mapping():
file_mapping = {}
sourcde_dir = 'data_backup/it_knowledge'
files = get_files_path(sourcde_dir, '.md')
count = 0
title_list = []
data_dir = 'data/1.dailycode初阶/4.it_knowledge'
for i in range(1, 104):
exercises_dir = os.path.join(data_dir, '{}.exercises'.format(i))
solution_md_path = os.path.join(exercises_dir, 'solution.md')
with open(solution_md_path, 'r') as f:
solution_md_data = f.read()
title = re.findall(r'^# (.*)\n', solution_md_data)[0]
title = title.strip()
for file in files:
print(file)
with open(file, 'r') as f:
source_file_data = f.read()
source_title = re.findall(r'## 标题\n(.*?)\n##', source_file_data, re.S)[0]
source_title = source_title.strip()
if title == source_title:
count+=1
title_list.append(title)
print(title)
print(source_title)
print(solution_md_path)
file_mapping[file] = solution_md_path
file_mapping_json = json.dumps(file_mapping, indent=2, ensure_ascii=False)
with open('data_backup/it_mapping.json', 'w', encoding='utf-8') as f:
f.write(file_mapping_json)
def update_it_konwledge():
data_dir = 'data_backup/it_knowledge'
it_mapping_path = 'data_backup/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()
difficulty = '简单'
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
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)
if file in exist_files:
save_path = it_mapping[file]
solution_md_data = f"# {question_title}\n\n{question_content}\n\n## 答案\n\n```{language}\n{answer}\n```\n\n## 选项\n\n### A\n\n```{language}\n{choice_list_remove[0]}\n```\n\n### B\n\n```{language}\n{choice_list_remove[1]}\n```\n\n### C\n\n```{language}\n{choice_list_remove[2]}\n```"
with open(save_path, 'w', encoding='utf-8') as f:
f.write(solution_md_data)
update_it_konwledge()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册