Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
沈秋雨
/
lyric_rhyme
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
04c78716
...
04c78716be35293f72e98d1818b214d4f53f5cae
authored
2026-06-27 14:13:13 +0800
by
沈秋雨
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix脚本添加转写为xlsx
1 parent
122cab3c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
3 deletions
results/fix_same_singer_samples.py
results/fix_same_singer_samples.py
View file @
04c7871
...
...
@@ -229,18 +229,49 @@ def main():
print
(
f
"移除行数: {len(removed)}(同歌手且时长相近)"
)
print
(
f
"保留行数: {len(kept)}"
)
# 写修复后的
CSV
(去掉冗余列)
# 写修复后的
文件
(去掉冗余列)
DROP_COLS
=
{
"topk_hit"
,
"expected_duplicate"
,
"predicted_duplicate"
,
"sample_class"
}
out_fieldnames
=
[
f
for
f
in
fieldnames
if
f
not
in
DROP_COLS
]
out_path
=
Path
(
args
.
output
)
with
out_path
.
open
(
"w"
,
newline
=
""
,
encoding
=
"utf-8"
)
as
f
:
# 输出 xlsx(原生支持 Unicode,Excel 打开不乱码)
xlsx_path
=
out_path
.
with_suffix
(
".xlsx"
)
import
openpyxl
from
openpyxl.styles
import
Font
,
PatternFill
,
Alignment
wb
=
openpyxl
.
Workbook
()
ws
=
wb
.
active
ws
.
title
=
"eval"
# 表头加粗 + 浅灰背景
header_font
=
Font
(
bold
=
True
)
header_fill
=
PatternFill
(
"solid"
,
fgColor
=
"D9D9D9"
)
ws
.
append
(
out_fieldnames
)
for
cell
in
ws
[
1
]:
cell
.
font
=
header_font
cell
.
fill
=
header_fill
cell
.
alignment
=
Alignment
(
horizontal
=
"center"
)
# 数据行
for
r
in
kept
:
ws
.
append
([
r
.
get
(
f
,
""
)
for
f
in
out_fieldnames
])
# 自适应列宽(最大 40 字符)
for
col
in
ws
.
columns
:
max_len
=
max
((
len
(
str
(
cell
.
value
or
""
))
for
cell
in
col
),
default
=
0
)
ws
.
column_dimensions
[
col
[
0
]
.
column_letter
]
.
width
=
min
(
max_len
+
2
,
40
)
wb
.
save
(
xlsx_path
)
print
(
f
"已写入: {xlsx_path}"
)
# 同时保留 CSV(utf-8-sig,Excel 双击也能正确识别中文)
with
out_path
.
open
(
"w"
,
newline
=
""
,
encoding
=
"utf-8-sig"
)
as
f
:
writer
=
csv
.
DictWriter
(
f
,
fieldnames
=
out_fieldnames
,
extrasaction
=
"ignore"
)
writer
.
writeheader
()
writer
.
writerows
(
kept
)
print
(
f
"已写入: {out_path}"
)
# 重新计算 summary
summary
=
compute_summary
(
kept
,
threshold
=
args
.
threshold
,
out_path
=
str
(
out
_path
))
summary
=
compute_summary
(
kept
,
threshold
=
args
.
threshold
,
out_path
=
str
(
xlsx
_path
))
summary_path
=
out_path
.
with_suffix
(
".summary.json"
)
with
summary_path
.
open
(
"w"
,
encoding
=
"utf-8"
)
as
f
:
json
.
dump
(
summary
,
f
,
ensure_ascii
=
False
,
indent
=
2
)
...
...
Please
register
or
sign in
to post a comment