43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
|
|
import pandas as pd
|
|
|
|
file_l2 = r'/root/.openclaw/workspace-xiaoyan/business_knowledge/L2单词表/L2新版独有单词.xlsx'
|
|
file_kb = r'/root/.openclaw/workspace-xiaoyan/business_knowledge/L2单词表/L2知识库-三级+A2.xlsx'
|
|
|
|
df_l2 = pd.read_excel(file_l2)
|
|
df_kb = pd.read_excel(file_kb)
|
|
|
|
available = df_l2[df_l2['可用'] == 1].copy()
|
|
|
|
new_rows = []
|
|
for _, row in available.iterrows():
|
|
new_rows.append({
|
|
'单词': row['单词'],
|
|
'词性': row['词性'],
|
|
'中文释义': row['词义'],
|
|
'KET/三级重合': '',
|
|
'分类': '',
|
|
'Unnamed: 5': '',
|
|
'与L1重复': row['是否为L1单词'],
|
|
'L1词性': row['L1词性'] if pd.notna(row['L1词性']) else '',
|
|
'L1词义': row['L1词义'] if pd.notna(row['L1词义']) else '',
|
|
'在L1中的行数': row['L1行数'] if pd.notna(row['L1行数']) else '',
|
|
'删除': ''
|
|
})
|
|
|
|
df_new = pd.DataFrame(new_rows)
|
|
|
|
df_kb = pd.concat([df_kb, df_new], ignore_index=True)
|
|
|
|
df_kb = df_kb.sort_values(by='单词', key=lambda x: x.str.lower(), ignore_index=True)
|
|
|
|
output_path = r'/root/.openclaw/workspace-xiaoyan/business_knowledge/L2单词表/L2知识库-三级+A2.xlsx'
|
|
df_kb.to_excel(output_path, index=False)
|
|
|
|
print(f"已添加 {len(new_rows)} 个单词")
|
|
print(f"L2知识库总单词数: {len(df_kb)}")
|
|
print(f"\n已保存至: {output_path}")
|
|
print("\n添加的单词(按字母顺序):")
|
|
for i, row in df_new.sort_values(by='单词', key=lambda x: x.str.lower()).iterrows():
|
|
print(f" {row['单词']:<15} {str(row['词性']):<10} {row['中文释义']:<25} L1:{row['与L1重复']} L1词性:{row['L1词性']} L1词义:{row['L1词义']}")
|