ai_member_xiaoyan/compare_new_vs_old.py

32 lines
1.2 KiB
Python

import pandas as pd
file_new = r'/root/.openclaw/workspace-xiaoyan/business_knowledge/L2单词表/L2新版_L1重复标记.xlsx'
file_old = r'/root/.openclaw/workspace-xiaoyan/business_knowledge/L2单词表/L2知识库-三级+A2.xlsx'
df_new = pd.read_excel(file_new)
df_old = pd.read_excel(file_old)
old_words = set(str(w).strip().lower() for w in df_old.iloc[:, 0])
only_in_new = []
for idx, row in df_new.iterrows():
word = str(row['单词']).strip().lower()
if word not in old_words:
only_in_new.append(row)
print(f"L2新版总单词数: {len(df_new)}")
print(f"L2知识库总单词数: {len(df_old)}")
print(f"\nL2新版中存在但L2知识库中不存在的单词: {len(only_in_new)}")
# 保存到文件
with open('/root/.openclaw/workspace-xiaoyan/only_in_new.txt', 'w', encoding='utf-8') as f:
f.write(f"L2新版中存在但L2知识库中不存在的单词: {len(only_in_new)}\n")
f.write("=" * 60 + "\n")
f.write(f"{'序号':<5} {'单词':<35} {'词性':<12} {'词义'}\n")
f.write("-" * 80 + "\n")
for i, row in enumerate(only_in_new, 1):
f.write(f"{i:<5} {str(row['单词']):<35} {str(row['词性']):<12} {str(row['词义'])}\n")
print("\n完整列表已保存到 only_in_new.txt")