File tree Expand file tree Collapse file tree 7 files changed +456
-363
lines changed
Expand file tree Collapse file tree 7 files changed +456
-363
lines changed Original file line number Diff line number Diff line change 11/Novel_Src
2- /vectorstore
3- /.conda
2+ /.venv
43/build
54/dist
65/.vscode
76/__pycache__
7+ /vectorstore
88config.json
Original file line number Diff line number Diff line change 1+ # chapter_directory_parser.py
2+ # -*- coding: utf-8 -*-
3+ import re
4+
5+ def get_chapter_info_from_directory (novel_directory_content : str , chapter_number : int ):
6+ """
7+ 从给定的 novel_directory_content 文本中,解析 “第X章” 行,并提取本章的标题和可能的简述。
8+ 返回一个 dict: {
9+ "chapter_title": <字符串>,
10+ "chapter_brief": <字符串> (若没有则为空)
11+ }
12+ 注意:目录文本示例格式:
13+ 第1章 :潮起
14+ 第2章 :阴影浮现 - 主要角色冲突爆发
15+ ...
16+ 也可能没有简述,只有一个简单标题。
17+ """
18+
19+ # 将文本逐行拆分
20+ lines = novel_directory_content .splitlines ()
21+
22+ # 章节匹配:形如 “第5章 :xxx” or “第5章: xxx” or “第5章 xxx”
23+ pattern = re .compile (r'^第\s*(\d+)\s*章\s*[::]?\s*(.*)$' )
24+
25+ for line in lines :
26+ match = pattern .match (line .strip ())
27+ if match :
28+ chap_num = int (match .group (1 ))
29+ if chap_num == chapter_number :
30+ # group(2) 可能是标题及简述的混合
31+ full_title = match .group (2 ).strip ()
32+ # 这里假设用 '-' 进一步区分“标题 - 简述”,也可能用户没写“ - ”
33+ if ' - ' in full_title :
34+ # 根据你的目录格式自由处理
35+ parts = full_title .split (' - ' , 1 )
36+ return {
37+ "chapter_title" : parts [0 ].strip (),
38+ "chapter_brief" : parts [1 ].strip ()
39+ }
40+ else :
41+ return {
42+ "chapter_title" : full_title ,
43+ "chapter_brief" : ""
44+ }
45+
46+ # 如果没有匹配到,返回默认
47+ return {
48+ "chapter_title" : f"第{ chapter_number } 章" ,
49+ "chapter_brief" : ""
50+ }
Original file line number Diff line number Diff line change 55
66def main ():
77 root = tk .Tk ()
8- root .title ("Novel Generator - Innovative Flow " )
8+ root .title ("Novel Generator" )
99 app = NovelGeneratorGUI (root )
1010 root .mainloop ()
1111
Original file line number Diff line number Diff line change 11# -*- mode: python ; coding: utf-8 -*-
2-
2+ from PyInstaller . utils . hooks import collect_submodules
33
44a = Analysis (
55 ['main.py' ],
66 pathex = [],
77 binaries = [],
8- datas = [],
8+ datas = [
9+ ('vectorstore' , 'vectorstore' )
10+ ],
911 hiddenimports = ['typing_extensions' ,
1012 'langchain-openai' ,
1113 'langgraph' ,
@@ -17,7 +19,15 @@ a = Analysis(
1719 'langchain-community' ,
1820 'pydantic' ,
1921 'pydantic.deprecated.decorator' ,
20- 'chromadb.utils.embedding_functions.onnx_mini_lm_l6_v2'
22+ * collect_submodules ('chromadb' ),
23+ 'chromadb.utils.embedding_functions.onnx_mini_lm_l6_v2' ,
24+ 'chromadb.telemetry.product.posthog' ,
25+ 'chromadb.api.segment' ,
26+ 'chromadb.db.impl' ,
27+ 'chromadb.db.impl.sqlite' ,
28+ 'chromadb.migrations' ,
29+ 'chromadb.migrations.embeddings_queue'
30+
2131 ],
2232 hookspath = [],
2333 hooksconfig = {},
You can’t perform that action at this time.
0 commit comments