Neighbourhood Safety Incident Reporting analysis library
Project description
incident-analysis-nci
A Python library for classifying, validating, analysing, and formatting neighbourhood safety incident reports.
Author: Adithya Reddy Version: 1.0.0
Installation
pip install incident-analysis-nci
Or install from source:
pip install -e .
Features
- IncidentClassifier — Classify incidents by type, severity, and priority using keyword matching
- ReportValidator — Validate and sanitise incident reports and user data
- SafetyAnalytics — Generate statistics, hotspot maps, trend data, and safety reports
- IncidentFormatter — Format incidents for display, CSV export, and SNS alert notifications
Quick Start
from incident_lib import IncidentClassifier, ReportValidator, SafetyAnalytics, IncidentFormatter
# Classify an incident
clf = IncidentClassifier()
category = clf.classify_incident("Someone stole my bike from the rack")
print(category) # "theft"
print(clf.get_severity_level(category)) # "high"
# Validate a report
val = ReportValidator()
valid, errors = val.validate_report({
"title": "Bike stolen on Main St",
"description": "My mountain bike was stolen from outside the shop at 10pm.",
"category": "theft",
"location": "Main Street",
})
print(valid) # True
# Analytics
analytics = SafetyAnalytics()
stats = analytics.get_incident_stats(incidents)
hotspots = analytics.get_hotspot_areas(incidents)
report = analytics.generate_safety_report(incidents, "Dublin 1")
# Formatting
fmt = IncidentFormatter()
print(fmt.format_incident_summary(incident))
print(fmt.to_csv(incidents))
print(fmt.format_alert(incident))
Dependencies
None — uses Python standard library only (re, datetime, csv, io, collections, math).
Running Tests
python -m pytest tests/ -v
Or with unittest:
python -m unittest discover tests -v
Incident Categories
| Category | Severity |
|---|---|
| assault | critical |
| fire | critical |
| theft | high |
| accident | high |
| flooding | high |
| vandalism | medium |
| suspicious_activity | medium |
| noise_complaint | low |
| other | low |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file incident_analysis_nci-1.0.0.tar.gz.
File metadata
- Download URL: incident_analysis_nci-1.0.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31050afc5d9b0c8ac6b37ebd74e5e54a71e208273c75f5da1b87f5b43bbfefed
|
|
| MD5 |
44c73b064e76930c4f0fa94706e9c467
|
|
| BLAKE2b-256 |
b46411f81f1a4e01432a719c90db3a2f85c6d3c42703514f35efca75ecc7d2df
|
File details
Details for the file incident_analysis_nci-1.0.0-py3-none-any.whl.
File metadata
- Download URL: incident_analysis_nci-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d366f152678d58f5be49cd772b0ac86ddb18ceb63d6001b80ad059a3d1586f4f
|
|
| MD5 |
cc97b120f8d6909f24684fbf010de8a4
|
|
| BLAKE2b-256 |
257b2b2d1995ddd32505a7612c1fb1c2d423e7aaf3d61b412502699d22d47337
|