A FastAPI-based Named Entity Recognition (NER) API for detecting bank names using spaCy. The API supports customizable patterns, is Dockerized for easy deployment, and ready for cloud hosting.
- Detects bank names in text using spaCy's EntityRuler.
- Allows adding custom patterns dynamically via the
/train/endpoint. - Fast and lightweight using FastAPI.
- Dockerized for portability and easy deployment.
- CORS enabled for frontend integration.
bank-ner/
├── bank_patterns.json # JSON file with default bank patterns
├── main.py # FastAPI application
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
└── __pycache__/ # Compiled Python files
git clone https://github.com/kishore-144/bank-ner.gitpython3 -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windowspip install -r requirements.txtuvicorn main:app --reload --host 0.0.0.0 --port 8000Open http://localhost:8000/docs for the interactive API documentation.
- Endpoint:
/train/ - Method:
POST - Body:
{
"l1": [
{
"label": "BANK",
"pattern": "UAB"
},
{
"label": "BANK",
"pattern": "IDBI"
}
]
}- Response:
{"message": "2 patterns added"}- Endpoint:
/test/ - Method:
POST - Body:
{
"sentence": "I have accounts in SBI and HDFC Bank."
}- Response:
[
["SBI", "BANK"],
["HDFC Bank", "BANK"]
]docker build -t bank-ner-api .docker run -d -p 8000:8000 bank-ner-apidocker ps # Get container ID
docker stop <container_id>
docker rm <container_id>- The app can be deployed to Azure App Service, AWS ECS, Google Cloud Run, or any other container-hosting service.
- Ensure the Docker image exposes port
8000and the container is set to runuvicorn main:app --host 0.0.0.0 --port 8000.
- Python 3.11+
- FastAPI
- spaCy
- Docker (optional, for containerization)
- Fork the repo
- Create a new branch (
git checkout -b feature/xyz) - Make your changes
- Commit (
git commit -m 'Add feature xyz') - Push (
git push origin feature/xyz) - Open a pull request
This project is licensed under the MIT License.
Kishore Passionate about machine learning, web development, and building scalable APIs.