提交 65109568 编写于 作者: 张志晨

隐藏token

上级 877e9745
......@@ -11,3 +11,4 @@ data_source/dailycode
test.cpp
test.py
test.java
tree_algorithm_view.xlsx
\ No newline at end of file
......@@ -6,6 +6,8 @@ import collections
import uuid
import json
import shutil
import pandas as pd
from pyparsing import match_previous_expr
def get_files_path(file_dir, filetype='.txt'):
......@@ -518,4 +520,46 @@ def auto_gen_increment_exercises_template():
f.write(solution_md_data)
auto_gen_increment_exercises_template()
\ No newline at end of file
from fuzzywuzzy import fuzz
def add_skilltree_leaf_link():
data = pd.read_excel('tree_algorithm_view.xlsx')
dir_list = ['data/1.dailycode初阶', 'data/2.dailycode中阶', 'data/3.dailycode高阶']
languages = ['1.cpp', '2.java', '3.python']
cout = 0
for dir in dir_list:
for language in languages:
dest_dir = os.path.join(dir, language)
exercises_dirs_ = os.listdir(dest_dir)
exercises_dirs = []
for tem_dir in exercises_dirs_:
tem_dir = os.path.join(dest_dir, tem_dir)
if os.path.isdir(tem_dir):
solution_md_path = os.path.join(tem_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]
match_res = []
for idx, item in data.iterrows():
text = item[2] + '-' + item[3]
link = 'https://edu.csdn.net/skill/algorithm/{}'.format(item[4])
match_score = fuzz.partial_ratio(title, text)
match_res.append(match_score)
max_score = max(match_res)
index = match_res.index(max_score)
target = data.loc[index][3]
link = 'https://edu.csdn.net/skill/algorithm/{}'.format(data.loc[index][4])
solution_json_path = os.path.join(tem_dir, 'solution.json')
solution_json_data = load_json(solution_json_path)
solution_json_data['skilltree_link'] = link
dump_json(solution_json_path, solution_json_data)
print("query: ", title, "target: ", target, "max_score: ", max_score)
print(link)
add_skilltree_leaf_link()
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册