-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_csv.ts
More file actions
41 lines (32 loc) · 1.37 KB
/
Copy pathcheck_csv.ts
File metadata and controls
41 lines (32 loc) · 1.37 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
import * as fs from 'fs';
const csv = fs.readFileSync('src/utils/badWords.csv', 'utf-8');
const lines = csv.split('\n');
console.log('--- Checking CSV format ---');
console.log('Total lines:', lines.length);
// Check for lines with unusual characters
let issueCount = 0;
lines.forEach((line, i) => {
const cleaned = line.replace(/,/g, '').trim().toLowerCase();
// Check for double spaces, leading spaces, or special chars
if (line.includes(' ') || (line.startsWith(' ') && line.trim() !== '')) {
console.log(`Line ${i + 1} has spacing issue: "${line}"`);
issueCount++;
}
// Check for empty after cleaning
if (line.trim() !== '' && cleaned === '') {
console.log(`Line ${i + 1} becomes empty after cleaning: "${line}"`);
issueCount++;
}
});
console.log(`\nIssues found: ${issueCount}`);
// Test a few specific words
const badWords = lines.map(w => w.replace(/,/g, '').trim().toLowerCase()).filter(Boolean);
console.log('\n--- Testing specific words ---');
const testWords = ['stupid', 'idiot', 'hate', 'kill', 'abuse', 'violence', 'fuck', 'shit', 'ass'];
testWords.forEach(word => {
const found = badWords.includes(word);
console.log(`"${word}" in list: ${found}`);
});
// Check words that contain the test text
console.log('\n--- Words matching "stu" ---');
console.log(badWords.filter(w => w.includes('stu')).slice(0, 10));