Skip to content

Commit

Permalink
修改忽略规则
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulle-sabaf committed Feb 7, 2025
1 parent a51ed0c commit 856201d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 276 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# 无关文件
src/other/
# 基础数据
src/data/

# 临时性文件、报告和日志文件、草稿、沙盒
/**/* copy*
/**/*.otf
/**/report*
/**/*report*
/**/*sandbox*
/**/*.log

# 临时打印的文件
code/*.pdf
out/*.pdf
258 changes: 0 additions & 258 deletions code/sandbox.tex

This file was deleted.

42 changes: 25 additions & 17 deletions code/texcom.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -160,15 +160,8 @@
"\n",
" # end document\n",
" footer = r\"\\end\" + wrap(\"document\") + \"\\n\"\n",
" return header, footer\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
" return header, footer\n",
"\n",
"def read_text(path, format=\"散文\"):\n",
" \"\"\"Read raw text and formalize to json\n",
" Inputs: \n",
Expand Down Expand Up @@ -460,7 +453,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -1830,7 +1823,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1868,14 +1861,28 @@
"平均复现次数:3.6次\n",
"未复现字数:0字\n",
"\n",
"完整报告已保存至:report_发蒙识字_250205.txt\n"
"完整报告已保存至:../out/report_发蒙识字_2025-02-07_15-00-34.txt\n"
]
}
],
"source": [
"import re\n",
"from collections import defaultdict, Counter\n",
"from pathlib import Path\n",
"import os\n",
"from datetime import datetime\n",
"\n",
"def add_suffix(filename, path):\n",
" # 获取当前日期并格式化为 YYYYMMDD 格式\n",
" time_suffix = datetime.now().strftime(\"%Y-%m-%d_%H-%M-%S\")\n",
" \n",
" # 分离文件名和扩展名\n",
" name, extension = filename.rsplit('.', 1)\n",
" project_name = os.path.splitext(os.path.basename(path))[0]\n",
" \n",
" # 添加日期后缀并返回新文件名\n",
" new_filename = f\"{name}_{project_name}_{time_suffix}.{extension}\"\n",
" return new_filename\n",
"\n",
"def load_textbook(path):\n",
" textbook = load_cn_json(path)\n",
Expand Down Expand Up @@ -1972,7 +1979,6 @@
" \"lag\": xiezi_first - shizi_first if xiezi_first != float('inf') else -1\n",
" })\n",
"\n",
" \n",
" # 检测3:学习内容是否在课文中\n",
" for lesson in lessons:\n",
" num = lesson['numero']\n",
Expand Down Expand Up @@ -2036,8 +2042,10 @@
" print(\"=== 简要检查报告 ===\")\n",
" print(brief_report)\n",
" \n",
" Path(report_path).write_text(full_report, encoding='utf-8')\n",
" print(f\"\\n完整报告已保存至:{report_path}\")\n",
" report_final_path = add_suffix(report_path, path)\n",
" Path(report_final_path).write_text(full_report, encoding='utf-8')\n",
"\n",
" print(f\"\\n完整报告已保存至:{report_final_path}\")\n",
" return analysis\n",
"\n",
"def generate_brief_report(analysis, lessons):\n",
Expand Down Expand Up @@ -2211,7 +2219,7 @@
" \n",
" return '\\n'.join(report)\n",
"\n",
"analysis = analyze_textbook(\"../src/小学/发蒙识字.json\", \"report_发蒙识字_250205.txt\")"
"analysis = analyze_textbook(\"../src/小学/发蒙识字.json\", \"../out/report.txt\")"
]
},
{
Expand Down

0 comments on commit 856201d

Please sign in to comment.