Convert of openstreetmap/id-tagging-schema to RiveScript, the Artificial Intelligence Scripting Language (alternative to AIML)
No pip release yet, install from GitHub: pip install https://github.com/fititnt/openstreetmap-tags-to-rivescript/archive/main.zip
Just install via pypi:
pip install --upgrade osmtags2rive
# To see all options
osmtags2rive --help
A copy of https://github.com/openstreetmap/id-tagging-schema on local disk is necessary. The following example saves on a path that is discovered by the cli tool.
# Prepare the cache directory
git clone https://github.com/openstreetmap/id-tagging-schema.git ./id-tagging-schema
The exact path can be customized with --path-id-tagging-schema
option.
osmtags2rive --language=pt > example/brain/osm-tagging_pt.rive
osmtags2rive --language=pt --reverse-index > example/brain/osm-tagging-reverse_pt.rive
Check Rivescript website page for interpreters for other programming languages than python or the online playground. They all have a similar interface: allow you to deposit all files in a directory which is loaded by your interpreter.
Copy and paste the contents of all the files and run it.
Using Rive Python interpreter from https://github.com/aichaos/rivescript-python
# install the rivescript python library
pip install rivescript
# Run your application.
# This one is a very simple (no integration with Telegram, Slack, etc) as proof of concept.
python shell.py
# file shell.py
from rivescript import RiveScript
# bot = RiveScript(utf8=True)
bot = RiveScript()
bot.load_directory("./example/brain")
bot.sort_replies()
while True:
msg = input('You> ')
if msg == '/quit':
quit()
reply = bot.reply("localuser", msg)
print ('Bot>', reply)
Example of interaction (may change)
You> highway=residential
Bot> OpenStreetMap preset highway/residential def. Rua residencial
You> estrada desconhecida
Bot> [ERR: No Reply Matched]
You> /quit
@TODO fix spaces on reverse index; "estrada desconhecida", not only strictly "estradadesconhecida"
OpenStreetMap™ is a trademark of the OpenStreetMap Foundation, and is used with their permission. This project is not endorsed by or affiliated with the OpenStreetMap Foundation. (via OSMF Trademark_Policy)
Public domain