Integrate Datasight into Acorn
We need to integrate Datasight into our comments system and create representation of it in the admin dashboard.
-
Install Datasight Api Client https://code.oak-tree.tech/datico/dsac. You will need API key there, so you can ask Ethan about it.
-
Create model where we will save Datasight response:
- jid (primary key)
- comment(foreign key)
- Section
- Keyword
- Named Entity
- Sentiment
- Toxicity
- Threat
- Obscene
- Sexual Explicit
- Identity Attack
- Severe Toxicity
- Create post save signal for Comment model and make request with dsac. Example of request you can find on the dsac gitlab main page. You shouldn't harcode operations value, create checkbox in setting where admin can choose operations. Example of using:
In [3]: dsac.job(
...: text='''This is the story of how I die. Welcome to the jungle.''',
...: operations=['keyword', 'sentiment', 'threat', 'named_entity'],
...: tags=['testing']
...: )
Out[3]:
{'status': 'complete',
'result': {'threat': [0.23668, 0.00461],
'named_entity': [[], []],
'keyword': [{'story': 1.0}, {'jungle': 0.5, 'Welcome': 0.5}],
'sentiment': [0.6036, 0.54751],
'section': ['This is the story of how I die.', 'Welcome to the jungle.']},
'jid': '5c35dbcc-68ef-4cd7-8006-ac0ee8dd69ed'}
-
Parse response data and add it to the database (Use model that you create earlier. Example of parsing this data you can find in the
Datasight Dashboard
project, but probably you don't need to use dataframe for it). -
Create child modeladmin for existing Comment modeladmin in the Wagtail dashbord and represent data of new Model there (Example of it you can find in Compass app, find how we represent details of community.ski_resorts)