An intelligent pipeline designed for e-commerce to bridge the gap between messy user inputs (voice-to-text, regional dialects) and clean, queryable geographic data.
E-commerce logistics often fail due to "dirty" address data:
- Phonetic Errors: "Devas" vs "Dewas" (Common in Voice-to-Text).
- Language Barriers: Regional scripts (Hindi/Marathi/etc.) are difficult to query in standard SQL databases.
- Spelling Inconsistency: Non-standard transliteration of local landmarks.
This system implements a two-layer validation strategy to ensure high-fidelity data:
- AI Transliteration Layer: Powered by AI4Bharat Indic Transliteration to map regional scripts to phonetic Roman (English) script.
- OSM Validation Layer: Cross-references the output with OpenStreetMap (OSM) binary data (
.pbf) using Fuzzy String Matching to find the real-world geographic "Ground Truth."
- Backend: FastAPI (Python 3.10)
- Database: PostgreSQL + SQLAlchemy ORM
- NLP: AI4Bharat Indic-Transliteration
- Geo-Data: Osmium & OpenStreetMap (PBF parsing)
- Fuzzy Logic: TheFuzz (Levenshtein Distance)
AI-Transliteration/
├── Backend/
│ ├── db.py # Database connection & Session local
│ ├── models.py # SQLAlchemy Tables (submissions & normalized_data)
│ ├── schemas.py # Pydantic models for API validation
│ ├── crud_helper.py # Core Logic: Transliteration + OSM + Fuzzy Matching
│ ├── translit.py # AI4Bharat wrapper logic
| |── main.py
├── osm-data/ # Storage for local .pbf geographic files
├── main.py # FastAPI entry point & Routes
|── create_db.py
|── ingestion.py
└── requirements.txt # Project dependencies
Note: Python 3.10 is strictly recommended due to AI library dependencies.
python3.10 -m venv venv
source venv/bin/activate
pip install "pip<24.1"
pip --version
pip install ai4bharat-transliteration
pip install -r requirements.txtUpdate your PostgreSQL credentials in Backend/db.py, then initialize the tables:
python create_db.py
To maintain privacy and speed, we use local OSM extracts. Place your .pbf file in osm-data/.
# Example: Filtering for Ujjain to optimize performance
osmium tags-filter india-latest.osm.pbf addr:city=Ujjain -o osm-data/ujjain_filtered.osm.pbf
python ingestion.py
fastapi run main.py
- API Endpoint:
http://localhost:8000/submit - Interactive Docs:
http://localhost:8000/docs
{
"pin_code": 456001,
"state": "मध्य प्रदेश",
"city": "उज्जैन",
"locality": "जवाहर मार्ग",
"landmark": "शांतिलाल मुन्नालाल एंड कंपनी"
}
- Ingestion: Receives Hindi/Regional text via FastAPI.
- Transliteration: AI4Bharat converts
जवाहर मार्ग→Jawahar Marg. - OSM Retrieval: The system scans local
.pbfdata for nodes/ways matching the Pincode. - Fuzzy Correction:
TheFuzzcomparesJawahar Margagainst all street names in the OSM extract. - Normalization: The most likely match (Ground Truth) is saved to the
normalized_datatable.