-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrules.js
More file actions
54 lines (47 loc) · 2.21 KB
/
Copy pathrules.js
File metadata and controls
54 lines (47 loc) · 2.21 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
(function (root, factory) {
const api = factory();
if (typeof module !== 'undefined' && module.exports) {
module.exports = api;
}
root.rules = api;
})(typeof globalThis !== 'undefined' ? globalThis : this, function () {
function normalizeText(text) {
if (typeof text !== 'string') return '';
return text
.toLowerCase()
.replace(/[^\w\sàâäéèêëïîôöùûüç’']/g, ' ')
.replace(/\s+/g, ' ')
.trim();
}
function predict(text) {
const normalized = normalizeText(text);
if (!normalized) {
return { score: 0, signals: [] };
}
const signals = [];
let score = 0;
const patterns = [
{ regex: /\b(?:frais de dossier|frais de traitement|frais administratifs|frais de réception)\b/i, weight: 28, label: 'frais de dossier' },
{ regex: /\b(?:virement|crypto|bitcoin|ether|usdt|wallet|versement)\b/i, weight: 30, label: 'demande d’argent ou crypto' },
{ regex: /\b(?:rib|pi[eè]ce d[’' ]?identit[ée]|carte d[’' ]?identit[ée]|passeport|cni)\b/i, weight: 32, label: 'demande de documents sensibles' },
{ regex: /\b(?:sans entretien|sans audition|embauche rapide|embauche immédiate|réponse immédiate)\b/i, weight: 20, label: 'embauche sans entretien' },
{ regex: /\b(?:gagner|gains?|revenu(?:s)? rapide(?:s)?|argent facile|argent rapidement|revenu extra)\b/i, weight: 24, label: 'promesse de gains' },
{ regex: /\b(?:whatsapp|telegram|signal|skype|messenger)\b/i, weight: 20, label: 'redirection hors plateforme' },
{ regex: /\b(?:urgence|urgent|immédiat|maintenant|tout de suite)\b/i, weight: 12, label: 'urgence' },
];
for (const rule of patterns) {
if (rule.regex.test(normalized)) {
score += rule.weight;
signals.push(rule.label);
}
}
if (signals.length >= 2) score += 8;
if (signals.length >= 3) score += 8;
if (normalized.includes('avant') && normalized.includes('entrevue')) score += 8;
if (normalized.includes('rib') && normalized.includes('identit')) score += 8;
if (normalized.includes('gagner') && normalized.includes('argent')) score += 8;
score = Math.min(score, 100);
return { score, signals };
}
return { predict, normalizeText };
});