-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-test-files.html
More file actions
553 lines (483 loc) · 20.3 KB
/
generate-test-files.html
File metadata and controls
553 lines (483 loc) · 20.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>重命名檢測測試 - 不同內容類型</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
max-width: 1200px;
width: 100%;
margin: 0 auto;
padding: 40px;
}
h1 {
color: #333;
text-align: center;
margin-bottom: 30px;
font-size: 2em;
}
.test-section {
margin-bottom: 30px;
padding: 20px;
background: #f8f9fa;
border-radius: 10px;
}
.test-section h2 {
color: #667eea;
margin-bottom: 15px;
font-size: 1.3em;
}
.test-card {
background: white;
padding: 15px;
margin-bottom: 15px;
border-radius: 8px;
border-left: 4px solid #667eea;
}
.test-card h3 {
color: #333;
margin-bottom: 10px;
font-size: 1.1em;
}
.test-card ul {
list-style: none;
padding-left: 20px;
}
.test-card li {
padding: 5px 0;
line-height: 1.6;
}
.similarity {
display: inline-block;
background: #d4edda;
color: #155724;
padding: 2px 8px;
border-radius: 4px;
font-weight: bold;
margin-left: 10px;
}
.buttons {
display: flex;
gap: 15px;
justify-content: center;
margin-top: 30px;
flex-wrap: wrap;
}
button {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 15px 30px;
border-radius: 10px;
font-size: 1.1em;
cursor: pointer;
transition: all 0.3s;
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}
.highlight {
background: #fff3cd;
padding: 15px;
border-left: 4px solid #ffc107;
border-radius: 5px;
margin-top: 15px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
font-size: 0.9em;
}
th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background: #667eea;
color: white;
}
.emoji {
font-size: 1.2em;
margin-right: 5px;
}
</style>
</head>
<body>
<div class="container">
<h1><span class="emoji">🔬</span>重命名檢測測試 - 不同內容類型</h1>
<div class="test-section">
<h2>測試目的:</h2>
<p>測試不同類型的表格內容是否會影響重命名檢測的準確度</p>
</div>
<div class="test-section">
<h2>測試案例:</h2>
<div class="test-card">
<h3>🔢 案例1: 數字密集型數據</h3>
<ul>
<li>Sheet名稱: <strong>Numbers</strong> → <strong>Digits</strong></li>
<li>內容: 100行 × 10列的隨機數字</li>
<li>修改: 僅2個數字不同 <span class="similarity">98% 相似度</span></li>
</ul>
</div>
<div class="test-card">
<h3>📝 案例2: 文字密集型數據</h3>
<ul>
<li>Sheet名稱: <strong>TextData</strong> → <strong>StringData</strong></li>
<li>內容: 50行文字描述(長字串)</li>
<li>修改: 僅3個詞不同 <span class="similarity">94% 相似度</span></li>
</ul>
</div>
<div class="test-card">
<h3>📅 案例3: 日期時間型數據</h3>
<ul>
<li>Sheet名稱: <strong>TimeLog</strong> → <strong>DateLog</strong></li>
<li>內容: 30行日期時間記錄</li>
<li>修改: 僅2個日期不同 <span class="similarity">93% 相似度</span></li>
</ul>
</div>
<div class="test-card">
<h3>🎨 案例4: 混合型數據</h3>
<ul>
<li>Sheet名稱: <strong>MixedData</strong> → <strong>CombinedData</strong></li>
<li>內容: 數字+文字+日期+布林值</li>
<li>修改: 僅4個值不同 <span class="similarity">92% 相似度</span></li>
</ul>
</div>
<div class="test-card">
<h3>🔳 案例5: 稀疏數據(多空格)</h3>
<ul>
<li>Sheet名稱: <strong>SparseData</strong> → <strong>SparseTable</strong></li>
<li>內容: 大量空儲存格的表格</li>
<li>修改: 僅2個非空值不同 <span class="similarity">95% 相似度</span></li>
</ul>
</div>
<div class="test-card">
<h3>📊 案例6: 公式密集型(純值)</h3>
<ul>
<li>Sheet名稱: <strong>Calculations</strong> → <strong>FormulasResult</strong></li>
<li>內容: 模擬公式計算結果(純數值)</li>
<li>修改: 僅3個計算結果不同 <span class="similarity">91% 相似度</span></li>
</ul>
</div>
<div class="test-card">
<h3>🌐 案例7: 多語言文字</h3>
<ul>
<li>Sheet名稱: <strong>中文數據</strong> → <strong>中文資料</strong></li>
<li>內容: 中文、英文、數字混合</li>
<li>修改: 僅2個中文詞不同 <span class="similarity">96% 相似度</span></li>
</ul>
</div>
<div class="test-card">
<h3>📏 案例8: 極小表格</h3>
<ul>
<li>Sheet名稱: <strong>TinySheet</strong> → <strong>SmallSheet</strong></li>
<li>內容: 僅5行 × 3列</li>
<li>修改: 僅1個值不同 <span class="similarity">93% 相似度</span></li>
</ul>
</div>
</div>
<div class="test-section">
<h2>預期結果:</h2>
<table>
<thead>
<tr>
<th>案例</th>
<th>內容類型</th>
<th>數據量</th>
<th>相似度</th>
<th>應該檢測為重命名?</th>
</tr>
</thead>
<tbody>
<tr>
<td>案例1</td>
<td>數字密集</td>
<td>1000 cells</td>
<td>98%</td>
<td>✅ 是</td>
</tr>
<tr>
<td>案例2</td>
<td>文字密集</td>
<td>200 cells</td>
<td>94%</td>
<td>✅ 是</td>
</tr>
<tr>
<td>案例3</td>
<td>日期時間</td>
<td>120 cells</td>
<td>93%</td>
<td>✅ 是</td>
</tr>
<tr>
<td>案例4</td>
<td>混合型</td>
<td>300 cells</td>
<td>92%</td>
<td>✅ 是</td>
</tr>
<tr>
<td>案例5</td>
<td>稀疏數據</td>
<td>400 cells (多空)</td>
<td>95%</td>
<td>✅ 是</td>
</tr>
<tr>
<td>案例6</td>
<td>公式結果</td>
<td>200 cells</td>
<td>91%</td>
<td>✅ 是</td>
</tr>
<tr>
<td>案例7</td>
<td>多語言</td>
<td>150 cells</td>
<td>96%</td>
<td>✅ 是</td>
</tr>
<tr>
<td>案例8</td>
<td>極小表格</td>
<td>15 cells</td>
<td>93%</td>
<td>✅ 是</td>
</tr>
</tbody>
</table>
</div>
<div class="highlight">
<strong><span class="emoji">💡</span> 重點:</strong>
這個測試將幫助你了解:
<ul style="margin-top: 10px; padding-left: 20px;">
<li>✅ 數字、文字、日期等不同數據類型是否影響檢測</li>
<li>✅ 稀疏數據(多空格)是否影響相似度計算</li>
<li>✅ 表格大小(從15個cell到1000個cell)是否影響檢測</li>
<li>✅ 多語言文字是否影響檢測準確度</li>
</ul>
</div>
<div class="buttons">
<button onclick="downloadFileA()">
<span class="emoji">📥</span> 下載 File A
</button>
<button onclick="downloadFileB()">
<span class="emoji">📥</span> 下載 File B
</button>
<button onclick="downloadBoth()" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); font-size: 1.2em; padding: 18px 40px;">
<span class="emoji">⚡</span> 一鍵下載兩個文件
</button>
</div>
</div>
<script>
// 案例1: 數字密集型
function generateNumbersData(isFileB = false) {
const data = [['Col1', 'Col2', 'Col3', 'Col4', 'Col5', 'Col6', 'Col7', 'Col8', 'Col9', 'Col10']];
for (let i = 1; i <= 100; i++) {
const row = [];
for (let j = 1; j <= 10; j++) {
let value = 1000 + i * 10 + j;
// 僅修改2個值
if (isFileB && i === 25 && j === 5) value += 100;
if (isFileB && i === 75 && j === 8) value -= 50;
row.push(value);
}
data.push(row);
}
return data;
}
// 案例2: 文字密集型
function generateTextData(isFileB = false) {
const data = [['Description', 'Category', 'Notes', 'Status']];
const descriptions = [
'This is a detailed description of the product features and specifications',
'Customer feedback indicates high satisfaction with the service quality',
'The quarterly report shows significant improvement in all key metrics',
'Implementation of new procedures has streamlined the workflow process',
'Analysis of market trends reveals emerging opportunities for growth'
];
for (let i = 0; i < 50; i++) {
let desc = descriptions[i % 5];
let category = `Category ${(i % 10) + 1}`;
let notes = `Additional notes for item ${i + 1}`;
let status = 'Active';
// 僅修改3個詞
if (isFileB && i === 10) desc = desc.replace('detailed', 'comprehensive');
if (isFileB && i === 25) category = 'Updated Category';
if (isFileB && i === 40) notes = notes.replace('Additional', 'Important');
data.push([desc, category, notes, status]);
}
return data;
}
// 案例3: 日期時間型
function generateDateData(isFileB = false) {
const data = [['Date', 'Time', 'Timestamp', 'Day']];
const baseDate = new Date('2024-01-01');
for (let i = 0; i < 30; i++) {
const date = new Date(baseDate);
date.setDate(date.getDate() + i);
let dateStr = date.toISOString().split('T')[0];
let timeStr = `${8 + (i % 12)}:00:00`;
let timestamp = date.getTime();
let day = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'][i % 7];
// 僅修改2個日期
if (isFileB && i === 10) {
dateStr = '2024-01-12';
}
if (isFileB && i === 20) {
timeStr = '15:30:00';
}
data.push([dateStr, timeStr, timestamp, day]);
}
return data;
}
// 案例4: 混合型數據
function generateMixedData(isFileB = false) {
const data = [['ID', 'Name', 'Amount', 'Date', 'Active', 'Score']];
for (let i = 1; i <= 50; i++) {
let id = i;
let name = `Item ${i}`;
let amount = 1000 + i * 50;
let date = `2024-01-${String(i % 28 + 1).padStart(2, '0')}`;
let active = i % 2 === 0;
let score = 50 + (i % 50);
// 僅修改4個值
if (isFileB && i === 10) name = 'Modified Item 10';
if (isFileB && i === 20) amount = 9999;
if (isFileB && i === 30) date = '2024-02-01';
if (isFileB && i === 40) score = 100;
data.push([id, name, amount, date, active, score]);
}
return data;
}
// 案例5: 稀疏數據
function generateSparseData(isFileB = false) {
const data = [['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']];
for (let i = 1; i <= 40; i++) {
const row = new Array(10).fill('');
// 只有少數儲存格有值
if (i % 4 === 0) row[0] = i;
if (i % 5 === 0) row[2] = `Value ${i}`;
if (i % 6 === 0) row[5] = i * 100;
if (i % 7 === 0) row[8] = 'X';
// 僅修改2個非空值
if (isFileB && i === 20) row[2] = 'Changed Value';
if (isFileB && i === 30) row[5] = 99999;
data.push(row);
}
return data;
}
// 案例6: 公式計算結果
function generateCalculationsData(isFileB = false) {
const data = [['Input', 'Double', 'Square', 'Sum', 'Avg']];
for (let i = 1; i <= 40; i++) {
let input = i;
let double = i * 2;
let square = i * i;
let sum = i + (i * 2) + (i * i);
let avg = sum / 3;
// 僅修改3個計算結果
if (isFileB && i === 15) double = 999;
if (isFileB && i === 25) square = 888;
if (isFileB && i === 35) avg = 777;
data.push([input, double, square, sum, avg.toFixed(2)]);
}
return data;
}
// 案例7: 多語言文字
function generateMultiLangData(isFileB = false) {
const data = [['中文', 'English', '數字', '混合']];
const chineseWords = ['產品', '服務', '品質', '客戶', '銷售', '利潤', '市場', '分析', '報告', '數據'];
const englishWords = ['Product', 'Service', 'Quality', 'Customer', 'Sales', 'Profit', 'Market', 'Analysis', 'Report', 'Data'];
for (let i = 0; i < 30; i++) {
let chinese = chineseWords[i % 10];
let english = englishWords[i % 10];
let number = 1000 + i * 100;
let mixed = `${chinese}-${english}-${number}`;
// 僅修改2個中文詞
if (isFileB && i === 10) chinese = '更新後的產品';
if (isFileB && i === 20) mixed = '新的混合數據-Updated-2500';
data.push([chinese, english, number, mixed]);
}
return data;
}
// 案例8: 極小表格
function generateTinyData(isFileB = false) {
const data = [
['A', 'B', 'C'],
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[10, 11, 12],
[13, 14, 15]
];
// 僅修改1個值
if (isFileB) {
data[3][1] = 999; // 修改第3行第2列
}
return data;
}
// 生成 File A
function generateFileA() {
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateNumbersData(false)), 'Numbers');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateTextData(false)), 'TextData');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateDateData(false)), 'TimeLog');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateMixedData(false)), 'MixedData');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateSparseData(false)), 'SparseData');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateCalculationsData(false)), 'Calculations');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateMultiLangData(false)), '中文數據');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateTinyData(false)), 'TinySheet');
return wb;
}
// 生成 File B
function generateFileB() {
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateNumbersData(true)), 'Digits');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateTextData(true)), 'StringData');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateDateData(true)), 'DateLog');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateMixedData(true)), 'CombinedData');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateSparseData(true)), 'SparseTable');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateCalculationsData(true)), 'FormulasResult');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateMultiLangData(true)), '中文資料');
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(generateTinyData(true)), 'SmallSheet');
return wb;
}
function downloadFileA() {
const wb = generateFileA();
XLSX.writeFile(wb, 'Rename_Test_FileA.xlsx');
}
function downloadFileB() {
const wb = generateFileB();
XLSX.writeFile(wb, 'Rename_Test_FileB.xlsx');
}
function downloadBoth() {
downloadFileA();
setTimeout(() => {
downloadFileB();
}, 500);
}
</script>
</body>
</html>