From 1e85c429ceaad860aba16d1f518160d263c094c0 Mon Sep 17 00:00:00 2001 From: lyg <1543117173@qq.com> Date: 星期二, 08 四月 2025 11:48:52 +0800 Subject: [PATCH] 生成指令帧和包格式结构 --- main.py | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 701bf1d..7508d18 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ +import math import os -from lang_flow import LangFlow -from markitdown import MarkItDown + +from knowledgebase.markitdown import MarkItDown from doc_to_docx import doc_to_docx @@ -25,10 +26,10 @@ if file.endswith(".docx"): # 杞崲涓� md result = md.convert(dst_dir + file) - text += '\n\n' + result.text_content - out_file = dst_dir + 'docs.md' - with open(out_file, 'w', encoding='utf-8') as f: - f.write(text) + text = result.text_content + out_file = dst_dir + file + '.md' + with open(out_file, 'w', encoding='utf-8') as f: + f.write(text) return out_file @@ -36,18 +37,29 @@ # 2.杈撳叆鏂囨。 # 3.鍚姩LangFlow def main(): - # doc_dir = "D:\\workspace\\PythonProjects\\KnowledgeBase\\doc\\" + doc_dir = ".\\doc\\" # 澶勭悊鏂囨。 # process_docs(doc_dir) # 鏂囨。杞崲涓簃arkdown - # md_file = to_markdown(doc_dir) + md_file = to_markdown(doc_dir) md_file = 'D:\\workspace\\PythonProjects\\KnowledgeBase\\doc\\test.md' # 鍚姩澶фā鍨嬪鐞嗘祦绋� - ret_text = LangFlow([md_file]).run() + # ret_text = LangFlow([md_file]).run() # 淇濆瓨缁撴灉 # with open('D:\\workspace\\PythonProjects\\KnowledgeBase\\doc\\test.text', 'w', encoding='utf-8') as f: # f.write(ret_text) + +def get_bit_mask(start, end): + bits = math.ceil((end + 1) / 8) * 8 + if bits == 0: + bits = 8 + mask = 0 + for i in range(start, end + 1): + mask |= 1 << (bits - i - 1) + return mask + + if __name__ == '__main__': - main() + main() \ No newline at end of file -- Gitblit v1.9.1