mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-07-11 19:18:40 +00:00
Add project files:
- Add database initialization scripts - Add configuration files - Add documentation - Add public assets - Add source code structure - Update README
This commit is contained in:
30
src/lib/utils/dataCleanup.ts
Normal file
30
src/lib/utils/dataCleanup.ts
Normal file
@ -0,0 +1,30 @@
|
||||
export function normalizePhoneNumber(phone: string): string {
|
||||
return phone.replace(/[^\d]/g, '');
|
||||
}
|
||||
|
||||
export function normalizeAddress(address: string): string {
|
||||
// Remove common suffixes and standardize format
|
||||
return address
|
||||
.toLowerCase()
|
||||
.replace(/(street|st\.?|avenue|ave\.?|road|rd\.?)/g, '')
|
||||
.trim();
|
||||
}
|
||||
|
||||
export function extractZipCode(text: string): string | null {
|
||||
const match = text.match(/\b\d{5}(?:-\d{4})?\b/);
|
||||
return match ? match[0] : null;
|
||||
}
|
||||
|
||||
export function calculateReliabilityScore(business: Business): number {
|
||||
let score = 0;
|
||||
|
||||
// More complete data = higher score
|
||||
if (business.phone) score += 2;
|
||||
if (business.website) score += 1;
|
||||
if (business.email) score += 1;
|
||||
if (business.hours) score += 2;
|
||||
if (business.services.length > 0) score += 1;
|
||||
if (business.reviewCount > 10) score += 2;
|
||||
|
||||
return score;
|
||||
}
|
Reference in New Issue
Block a user