提交 ca3bba33 编写于 作者: F feilong

init skill_tree_c dir, add readme

上级 bad2d2b8
.vscode
.idea
.DS_Store
__pycache__
*.pyc
*.zip
\ No newline at end of file
# skill_tree_c
## 初始化
```
pip install -r requirement.txt
```
## 目录结构说明
* 技能树`骨架文件`
* 位置:`data/tree.json`
* 说明:该文件是执行 `python main.py` 生成的,请勿人工编辑
* 技能树`根节点`配置文件:
* 位置:`data/config.json`
* 说明:可编辑配置关键词等字段,其中 `node_id` 字段是生成的,请勿编辑
* 技能树`难度节点`
* 位置:`data/xxx`,例如: `data/1.C语言初阶`
* 说明:
* 每个技能树有 3 个等级,目录前的序号是必要的,用来保持文件夹目录的顺序
* 每个目录下有一个 `config.json` 可配置关键词信息,其中 `node_id` 字段是生成的,请勿编辑
* 技能树`章节点`
* 位置:`data/xxx/xxx`,例如:`data/1.C语言初阶/1.C语言概述`
* 说明:
* 每个技能树的每个难度等级有 n 个章节,目录前的序号是必要的,用来保持文件夹目录的顺序
* 每个目录下有一个 `config.json` 可配置关键词信息,其中 `node_id` 字段是生成的,请勿编辑
* 技能树`知识节点`
* 位置:`data/xxx/xxx`,例如:`data/1.C语言初阶/1.C语言概述`
* 说明:
* 每个技能树的每章有 n 个知识节点,目录前的序号是必要的,用来保持文件夹目录的顺序
* 每个目录下有一个 `config.json`
* 其中 `node_id` 字段是生成的,请勿编辑
* 其中 `keywords` 可配置关键字字段
* 其中 `children` 可配置该`知识节点`下的子树结构信息,参考后面描述
* 其中 `export` 可配置该`知识节点`下的导出习题信息,参考后面描述
## `知识节点` 子树信息结构
例如 `data/1.C语言初阶/1.C语言概述/1.C语言发展史/config.json` 里配置对该知识节点子树信息结构:
```json
{
// ...
"children": [
{
"C语言的起源": {
"keywords": [
"C语言的起源",
"起源",
"C语言"
],
"children": []
}
},
{
"C语言的发展与应用": {
"keywords": [
"C语言的发展",
"C语言的应用",
"发展",
"应用",
"C语言"
],
"children": []
}
}
],
}
```
## `知识节点` 的导出习题编辑
例如 `data/1.C语言初阶/1.C语言概述/1.C语言发展史/config.json` 里配置对该知识节点导出的习题
```json
{
// ...
"export": [
{
"file": "helloworld.c",
"variants": "helloworld.json",
"depends": []
},
// ...
]
}
```
格式说明:
* `file`: 指定该目录下的习题源文件
* `variants`: 指定习题同名的json选项配置文件,参考下一节
* `depends`: 如果习题依赖同目录下的其他习题源代码,则在此字段里配置依赖的其他习题源文件名
## `知识节点` 的导出习题选项配置编辑
首先,在知识节点下增加一个习题代码,例如在 `data/1.C语言初阶/1.C语言概述/1.C语言发展史/` 下增加一个`helloworld.c`代码:
```c
#include <stdio.h>
int main(int argc, char** argv){
printf("Hello,Wrold!");
return 0;
}
```
其次,增加一个同名的选项配置文件`helloworld.json`,目前有两种配置规则
**单行替换规则**
* 配置由`one_line`字段指定的单行替换字典
* 格式是:`"<源字符串>"`: [`"<替换字符串A>"`, `<替换字符串B>`,...],
* 其中每个 `"<源字符串>"` `/` `"<替换字符串A>"` 被生成为是一个替换选项
* 指定的配置应该能至少生成 `3+` 个替换选项
```json
{
"one_line": {
"printf": ["print"],
"return 0;": ["return 0"],
"(\"Hello,Wrold!\")": [" \"Hello,Wrold!\""]
}
}
```
上面的替换规则会将代码替换成 3 个变种的代码:
```c
// 变种代码1
#include <stdio.h>
int main(int argc, char** argv){
print("Hello,Wrold!");
return 0;
}
```
```c
// 变种代码2
#include <stdio.h>
int main(int argc, char** argv){
print("Hello,Wrold!");
return 0
}
```
```c
// 变种代码3
#include <stdio.h>
int main(int argc, char** argv){
print "Hello,Wrold!";
return 0
}
```
这些变种代码将会作为技能树该知识点该代码选择题的选项。
**多行替换规则**
* 配置由`multiline`字段指定的多行替换数组
* 数组的每个元素是一组替换规则,会整组被替换
例如:
```json
{
"multiline": [
{
"printf": "print"
},
{
"int main(int argc, char** argv){" : "int main(char** argv){",
"return 0;" : "return 0",
},
{
"#include <stdio.h>": ""
}
]
}
```
同样,该配置将支持将源代码生成3个变种代码
```c
// 变种代码1
#include <stdio.h>
int main(int argc, char** argv){
print("Hello,Wrold!");
return 0;
}
```
```c
// 变种代码2, 注意第2组替换规则,包含了两行替换
#include <stdio.h>
int main(char** argv){
print("Hello,Wrold!");
return 0
}
```
```c
// 变种代码3
int main(int argc, char** argv){
print("Hello,Wrold!");
return 0;
}
```
## 技能树合成
在根目录下执行 `python main.py` 会合成技能树文件,合成的技能树文件: `data/tree.json`
* 合成过程中,会自动检查每个目录下 `config.json` 里的 `node_id` 是否存在,不存在则生成
* 合成过程中,会自动检查每个知识点目录下 `config.json` 里的 `export` 里导出的习题配置,检查是否存在`exercise_id` 字段,如果不存在则生成
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"C语言概述",
"概述",
"C语言"
],
"children": [
{
"C语言的起源": {
"keywords": [
"C语言的起源",
"起源",
"C语言"
],
"children": []
}
},
{
"C语言的发展与应用": {
"keywords": [
"C语言的发展",
"C语言的应用",
"发展",
"应用",
"C语言"
],
"children": []
}
}
],
"export": [
{
"file": "helloworld.c",
"variants": "helloworld.json",
"depends": []
}
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"C语言概述",
"概述",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数据类型",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数据类型",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数据类型",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数据类型",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数据类型",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数据类型",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数组",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数组",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数组",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数组",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数组",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数组",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"结构体",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"结构体",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"结构体",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"结构体",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"结构体",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"结构体",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"共用体",
"联合体",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"预处理器",
"预编译器",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"预处理器",
"预编译器",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"预处理器",
"预编译器",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"预处理器",
"预编译器",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"预处理器",
"预编译器",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"预处理器",
"预编译器",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"文件",
"C语言"
],
"children": [
{
"文件指针": {
"keywords": [
"文件指针",
"文件"
],
"children": []
}
},
{
"文件的打开": {
"keywords": [
"文件的打开",
"文件",
"文件打开"
],
"children": []
}
},
{
"文件的关闭": {
"keywords": [
"文件的关闭",
"文件",
"文件关闭"
],
"children": []
}
}
],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"文件",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"文件",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"存储管理",
"内存管理",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"存储管理",
"内存管理",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"存储管理",
"内存管理",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"标准函数库",
"标准库",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"标准函数库",
"标准库",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"标准函数库",
"标准库",
"C语言"
],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"标准函数库",
"标准库",
"C语言"
]
}
\ No newline at end of file
{
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": []
}
\ No newline at end of file
{
"tree_name": "C语言",
"keywords": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
\ No newline at end of file
{
"C语言": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [],
"children": [
{
"C语言初阶": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [],
"children": [
{
"C语言概述": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"C语言概述",
"概述",
"C语言"
],
"children": [
{
"C语言发展史": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"C语言概述",
"概述",
"C语言"
],
"children": [
{
"C语言的起源": {
"keywords": [
"C语言的起源",
"起源",
"C语言"
],
"children": []
}
},
{
"C语言的发展与应用": {
"keywords": [
"C语言的发展",
"C语言的应用",
"发展",
"应用",
"C语言"
],
"children": []
}
}
]
}
}
]
}
},
{
"数据类型": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数据类型",
"C语言"
],
"children": [
{
"变量与常量": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数据类型",
"C语言"
],
"children": []
}
},
{
"整数类型": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数据类型",
"C语言"
],
"children": []
}
},
{
"浮点类型": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数据类型",
"C语言"
],
"children": []
}
},
{
"字符类型": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数据类型",
"C语言"
],
"children": []
}
},
{
"布尔类型": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数据类型",
"C语言"
],
"children": []
}
}
]
}
},
{
"运算符": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": [
{
"赋值运算符": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
},
{
"逗号运算符": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
},
{
"位逻辑运算符": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
},
{
"sizeof运算符和size_t类型": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
},
{
"运算符优先级": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
},
{
"求值顺序": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
},
{
"加法运算符": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
},
{
"减法运算符": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
},
{
"符号运算符": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
},
{
"乘法运算符": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
},
{
"除法运算符": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
},
{
"求模运算符": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
},
{
"递增运算符": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
},
{
"递减运算符": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"运算符",
"C语言"
],
"children": []
}
}
]
}
},
{
"表达式": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
],
"children": [
{
"赋值表达式": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
],
"children": []
}
},
{
"算术表达式": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
],
"children": []
}
},
{
"关系表达式": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
],
"children": []
}
},
{
"逻辑表达式": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
],
"children": []
}
},
{
"位逻辑表达式": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
],
"children": []
}
},
{
"逗号表达式": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"表达式",
"C语言"
],
"children": []
}
}
]
}
},
{
"语句与控制流": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": [
{
"程序块": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": []
}
},
{
"if语句": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": []
}
},
{
"if-else语句": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": []
}
},
{
"else-if语句": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": []
}
},
{
"switch语句": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": []
}
},
{
"while循环与for循环": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": []
}
},
{
"do-while循环": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": []
}
},
{
"break语句与continue语句": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": []
}
},
{
"goto语句": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"语句",
"控制流",
"C语言"
],
"children": []
}
}
]
}
}
]
}
},
{
"C语言中阶": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [],
"children": [
{
"函数与程序结构": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": [
{
"函数的参数": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
},
{
"头文件": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
},
{
"外部变量": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
},
{
"静态变量": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
},
{
"寄存器变量": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
},
{
"程序块结构": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
},
{
"函数的返回": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
},
{
"函数的作用域规则": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
},
{
"函数的初始化": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
},
{
"函数的递归": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
},
{
"函数的声明": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
},
{
"函数的定义": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
},
{
"函数的调用": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
},
{
"内部函数和外部函数": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"函数",
"程序结构",
"C语言"
],
"children": []
}
}
]
}
},
{
"数组和指针": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数组",
"C语言"
],
"children": [
{
"数组简介": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数组",
"C语言"
],
"children": []
}
},
{
"一维数组": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数组",
"C语言"
],
"children": []
}
},
{
"二维数组": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数组",
"C语言"
],
"children": []
}
},
{
"多维数组": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数组",
"C语言"
],
"children": []
}
},
{
"变长数组": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"数组",
"C语言"
],
"children": []
}
}
]
}
},
{
"指针": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": [
{
"指针与地址": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": []
}
},
{
"指针与函数参数": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": []
}
},
{
"指针与数组": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": []
}
},
{
"地址算术运算": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": []
}
},
{
"字符指针与函数": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": []
}
},
{
"指针数组以及指向指针的指针": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": []
}
},
{
"指针与多维数组": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": []
}
},
{
"指向函数的指针": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"指针",
"C语言"
],
"children": []
}
}
]
}
}
]
}
},
{
"C语言高阶": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [],
"children": [
{
"结构体": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"结构体",
"C语言"
],
"children": [
{
"结构体简介": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"结构体",
"C语言"
],
"children": []
}
},
{
"结构体数组": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"结构体",
"C语言"
],
"children": []
}
},
{
"结构体指针": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"结构体",
"C语言"
],
"children": []
}
},
{
"结构体与函数": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"结构体",
"C语言"
],
"children": []
}
},
{
"链式结构": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"结构体",
"C语言"
],
"children": []
}
}
]
}
},
{
"联合体": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"共用体",
"联合体",
"C语言"
],
"children": []
}
},
{
"位运算": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": [
{
"位和字节": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": []
}
},
{
"二进制数": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": []
}
},
{
"八进制": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": []
}
},
{
"十六进制": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": []
}
},
{
"位逻辑运算符": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": []
}
},
{
"位字段": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": []
}
},
{
"对齐特性": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"位运算",
"位操作",
"C语言"
],
"children": []
}
}
]
}
},
{
"预处理器": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"预处理器",
"预编译器",
"C语言"
],
"children": [
{
"宏定义": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"预处理器",
"预编译器",
"C语言"
],
"children": []
}
},
{
"#include指令": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"预处理器",
"预编译器",
"C语言"
],
"children": []
}
},
{
"#undef指令": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"预处理器",
"预编译器",
"C语言"
],
"children": []
}
},
{
"条件编译": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"预处理器",
"预编译器",
"C语言"
],
"children": []
}
},
{
"内联函数": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"预处理器",
"预编译器",
"C语言"
],
"children": []
}
}
]
}
},
{
"文件": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"文件",
"C语言"
],
"children": [
{
"文件的基本操作": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"文件",
"C语言"
],
"children": [
{
"文件指针": {
"keywords": [
"文件指针",
"文件"
],
"children": []
}
},
{
"文件的打开": {
"keywords": [
"文件的打开",
"文件",
"文件打开"
],
"children": []
}
},
{
"文件的关闭": {
"keywords": [
"文件的关闭",
"文件",
"文件关闭"
],
"children": []
}
}
]
}
},
{
"文件的读写": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"文件",
"C语言"
],
"children": []
}
}
]
}
},
{
"存储管理": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"存储管理",
"内存管理",
"C语言"
],
"children": [
{
"存储类别": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"存储管理",
"内存管理",
"C语言"
],
"children": []
}
},
{
"分配内存:malloc()和free()": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"存储管理",
"内存管理",
"C语言"
],
"children": []
}
}
]
}
},
{
"标准函数库": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"标准函数库",
"标准库",
"C语言"
],
"children": [
{
"数学库": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"标准函数库",
"标准库",
"C语言"
],
"children": []
}
},
{
"通用工具库": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"标准函数库",
"标准库",
"C语言"
],
"children": []
}
},
{
"断言库 ": {
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"keywords": [
"标准函数库",
"标准库",
"C语言"
],
"children": []
}
}
]
}
}
]
}
}
]
}
}
\ No newline at end of file
from src.tree import gen_tree
if __name__ == '__main__':
gen_tree('data')
uuid==1.30
\ No newline at end of file
from genericpath import exists
import json
import os
import uuid
import sys
import re
def load_json(p):
with open(p, 'r') as f:
return json.loads(f.read())
def dump_json(p, j, exist_ok=False, override=False):
if os.path.exists(p):
if exist_ok:
if not override:
return
else:
print(f"{p} already exist")
sys.exit(0)
with open(p, 'w') as f:
f.write(json.dumps(j, indent=2, ensure_ascii=False))
def parse_no_name(d):
p = r'(\d+)\.(.*)'
m = re.search(p, d)
try:
no = int(m.group(1))
dir_name = m.group(2)
except:
sys.exit(0)
return no, dir_name
def gen_tree(data_path):
root = {}
def gen_node_id():
return ''.join(str(uuid.uuid5(uuid.NAMESPACE_URL, 'skill_tree')).split('-'))
def list_dir(p):
v = os.listdir(p)
v.sort()
for no_name in v:
no_dir = os.path.join(p, no_name)
if os.path.isdir(no_dir):
yield no_dir, no_name
def ensure_node_id(cfg_path, cfg):
if cfg.get('node_id') is None:
cfg['node_id'] = gen_node_id()
dump_json(cfg_path, cfg, exist_ok=True, override=True)
def make_node(name, node_id, keywords, children=None):
node = {}
node_children = children or []
node[name] = {
'node_id': node_id,
'keywords': keywords,
'children': node_children
}
return node, node_children
# 根节点
cfg_path = os.path.join(data_path, 'config.json')
cfg = load_json(cfg_path)
ensure_node_id(cfg_path, cfg)
tree_node = {
"node_id": cfg['node_id'],
"keywords": cfg['keywords'],
"children": []
}
root[cfg['tree_name']] = tree_node
# 难度节点
for level_no_dir, level_no_name in list_dir(data_path):
print(level_no_dir)
no, level_name = parse_no_name(level_no_name)
cfg_path = os.path.join(level_no_dir, 'config.json')
cfg = load_json(cfg_path)
ensure_node_id(cfg_path, cfg)
level_node, level_node_children = make_node(
level_name, cfg['node_id'], cfg['keywords'])
tree_node['children'].append(level_node)
# 章节点
for chapter_no_dir, chapter_no_name in list_dir(level_no_dir):
no, chapter_name = parse_no_name(chapter_no_name)
cfg_path = os.path.join(chapter_no_dir, 'config.json')
ensure_node_id(cfg_path, cfg)
cfg = load_json(cfg_path)
chapter_node, chapter_node_children = make_node(
chapter_name, cfg['node_id'], cfg['keywords'])
level_node_children.append(chapter_node)
# 知识点
for section_no_dir, section_no_name in list_dir(chapter_no_dir):
no, section_name = parse_no_name(section_no_name)
cfg_path = os.path.join(section_no_dir, 'config.json')
ensure_node_id(cfg_path, cfg)
cfg = load_json(cfg_path)
section_node, section_node_children = make_node(
section_name, cfg['node_id'], cfg['keywords'], cfg['children'])
chapter_node_children.append(section_node)
# 确保习题分配了习题ID
for export in cfg['export']:
if export.get('exercise_id') is None:
export['exercise_id'] = gen_node_id()
dump_json(cfg_path, cfg, exist_ok=True, override=True)
# 保存技能树骨架
tree_path = os.path.join(data_path, 'tree.json')
dump_json(tree_path, root, exist_ok=True, override=True)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册