Improved Related Alert Matching
No one like unnecessary or duplicate messages, whether from a bot or another human. Thus, we want Mobility Bot to keep the noise to a minimum. This stems from our background in incident response, because “alert fatigue” is real.
When working with 20+ different transit operators, we have to sometimes assume the worst but hope for the best with the quality of data we receive. Often, an alert will come in looking something like this:
The Maroon Line is currently bypassing the Springfield Ave stop due to a sick passenger. Expect 5-15 minute delays.
While some transit operators assign unique IDs to each alert, others do not. We might later see this alert:
The Maroon Line is currently bypassing the Springfield Ave stop due to a sick passenger. Expect 15-25 minute delays.
To a human, it is pretty clear these alerts are related- the only difference is the length of possible delay being reported. But since we can’t have a human manually review every alert - how can a computer determine this? Enter the Python RapidFuzz library, which allows computing a whole variety of string distance metrics.
from rapidfuzz import fuzz
one = (
"The Maroon Line is currently bypassing the Springfield Ave stop "
"due to a sick passenger. Expect 5-15 minute delays."
)
two = (
"The Maroon Line is currently bypassing the Springfield Ave stop "
"due to a sick passenger. Expect 15-25 minute delays."
)
score = fuzz.ratio(one, two)
print(score)
# 98.7012987012987
With a suitable cutoff value, it becomes possible to determine which alerts are related and thread these messages together, reducing noise. However, it is still important to do other sanity checks - the same message showing up for the Blue Line rather than Maroon Line would have a similar similarity ratio. Mobility Bot weighs several factors when determining if an alert is duplicate or related to an existing alert.
Related Posts
- Using Python asyncio in a standalone script
- Using Slack Bolt in a Python Litestar App
- Commute Hours Are Now More Flexible
🚌 Ensure your commute is smooth and hassle-free with Mobility Bot. Install it now in your Slack workspace!
🚇 Stay informed with real-time transit alerts tailored to your specific routes and schedule.