feat: implement geocoding evaluation scripts and enhance routing service with traffic-aware path processing
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const API_URL = process.env.TEST_API_URL || 'http://localhost:3200/api/geocoding/search';
|
||||
const API_KEY = process.env.TEST_API_KEY || 'zP9vL5mK2nQ8xR7jT4wS1yB6hG3fV0cX';
|
||||
|
||||
const testQueries = [
|
||||
"السمساني", // Should suggest "الشميساني"
|
||||
"جبل اللويبضة", // Wait, misspelled: "جبل اللوبيدة" ?
|
||||
"الاستفلال", // Should suggest "الاستقلال"
|
||||
"مستشفا الاوردن" // Should suggest "مستشفى الأردن"
|
||||
];
|
||||
|
||||
async function testDidYouMean() {
|
||||
console.log(`\n🚑 Testing 'Did You Mean?' (Spell Checker)\n`);
|
||||
|
||||
for (const q of testQueries) {
|
||||
try {
|
||||
const searchRes = await axios.get(API_URL, {
|
||||
headers: { 'x-api-key': API_KEY },
|
||||
params: { q, country: 'jordan' }
|
||||
});
|
||||
console.log(`🔍 Search for misspelled: "${q}"`);
|
||||
|
||||
if (searchRes.data.results?.length > 0) {
|
||||
console.log(` ✅ Found results: ${searchRes.data.results[0].name}`);
|
||||
} else if (searchRes.data.did_you_mean) {
|
||||
console.log(` ⚠️ 0 Results. Did you mean: ✨ "${searchRes.data.did_you_mean}" ✨ ?`);
|
||||
} else {
|
||||
console.log(` ❌ 0 Results. No suggestions found.`);
|
||||
}
|
||||
console.log('--------------------------------------------------');
|
||||
} catch (e: any) {
|
||||
console.log(`❌ Query "${q}" failed:`, e.response?.data || e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
testDidYouMean().catch(console.error);
|
||||
Reference in New Issue
Block a user