-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_detection_api.js
More file actions
29 lines (24 loc) · 854 Bytes
/
Copy pathtest_detection_api.js
File metadata and controls
29 lines (24 loc) · 854 Bytes
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
async function testDetection() {
const text = 'enculer';
console.log(`Testing detection for: "${text}"`);
try {
const response = await fetch('http://localhost:5001/detect', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ q: text })
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log('Response:', JSON.stringify(data, null, 2));
if (data[0].language === 'fr') {
console.log('✅ SUCCESS: Detected as French');
} else {
console.error('❌ FAILURE: Not detected as French');
}
} catch (error) {
console.error('Error:', error.message);
}
}
testDetection();