Logo Lanfrica

lakshmi-pedapudi/asset_normalizer

Domaine:

natural language processingagriculture

Type de record:

software
Créateur:
Lak
Hôte:
Canonical crop and livestock name normalization for multilingual agricultural queries (English, Hindi, Telugu, Kikuyu) # Asset Normalizer Standalone Python package for agricultural asset name normalization. Maps raw crop/livestock names (including misspellings, plurals, Indic-script variants, and STT garbles) to canonical forms using a multi-step matching pipeline. Extracted from CacheQA's `src/asset_normalizer.py` so that other projects (Deduplication_2o, future pipelines) can use it without CacheQA dependencies. ## Setup ```bash # Editable install (recommended for development): pip install -e /path/to/asset_normalizer # With DB sync support (PostgreSQL extraction): pip install -e '/path/to/asset_normalizer[db]' # Verify: python -c "from asset_normalizer import normalize_asset_name; print(normalize_asset_name('tomatoes'))" # → Tomato ``` ### Dependencies Declared in `pyproject.toml` and installed automatically: - `python-Levenshtein` — fuzzy string matching (Step 2b) - `metaphone` — Double Metaphone phonetic codes (Step 2c, Latin scripts) - `indic-transliteration` — ITRANS transliteration (Step 2c, Indic scripts) - `pandas` — bulk CSV/DataFrame normalization **Optional** (`pip install asset-normalizer[db]`): - `psycopg2-binary` — PostgreSQL connectivity for DB sync - `python-dotenv` — auto-load `.env` files for DB credentials ## CLI Installed as `asset-normalizer` (or `python -m asset_normalizer`): ### `normalize` — Normalize one or more names ```bash asset-normalizer normalize tomatoes tamatar "टमाटर" cow # tomatoes -> Tomato # tamatar -> Tomato # टमाटर -> Tomato # cow -> Cattle # With asset type hint: asset-normalizer normalize wheat --asset-type crop # JSON output: asset-normalizer normalize tomatoes --json # {"input": "tomatoes", "canonical": "Tomato"} ``` ### `spot` — Spot assets in a query string ```bash asset-normalizer spot "my tomato and wheat have pests" # Tomato, Durum Wheat asset-normalizer spot "मेरे टमाटर में कीटों की समस्या" --json # {"query": "...", "assets": ["Tomato"]} ``` ### `resolve` — Pre-classification asset resolution Resolves assets fr …