This page is being edited.
The bot is trying to discourage behaviour that violates the principles of constructive communication. Particularly it can detect simple insults in messages and ask to rephrase such messages. The attached function performs insult detection.
The function uses a wonderful framework for creating dialog systems of DeepPavlov
pip install deeppavlov
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
from deeppavlov import build_model, configs CONFIG_PATH = '/home/pi/bot/deeppavlov/configs/classifiers/insults_kaggle_conv_bert.json' model = build_model(CONFIG_PATH, download=True) def insult_detect(text): if model([text]) == ['Insult']: return True return False if __name__ == "__main__": while True: text = input('enter a question: ') print(insult_detect(text)) |
