sentiment-widget
v1.0.27
Published
Stencil Component Starter
Downloads
75
Readme
sentiment-widget
Quick Start
1. Import the packaged JS file
Create an html file and import the required libraries and the packaged js file in the header.
<!doctype html>
<html lang='en'>
<head>
...
<title>Document</title>
<script type="module" src="https://unpkg.com/[email protected]/dist/esm/sentiment.js"></script>
</head>
...
</html>
2. Use the tag
<!doctype html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport'
content='width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0'>
<meta http-equiv='X-UA-Compatible' content='ie=edge'>
<title>Document</title>
<script type="module" src="https://unpkg.com/[email protected]/dist/esm/sentiment.js"></script>
</head>
<body>
<sentiment-widget></sentiment-widget>
</body>
</html>
3. Custom attributes
type-prop
: Optional values areevent
andaddress
andabstract
, corresponding to key events and key addresses, with a default value ofevent
.lang-prop
: Optional values arezh
anden
, corresponding to Chinese (traditional) and English, with a default value ofzh
.api-key
: Specify theapi-key
, the valid client will receive the realtime data update.is-expand
: Specify theis-expand
ason
, the widget will compress in the pop up window button, default isoff
4. Example:
As basic user, if you want to initialize and display the event
key event using the English interface widget, you can use:
<sentiment-widget type-prop='event' lang-prop='en'></sentiment-widget>
or
<sentiment-widget lang-prop='en'></sentiment-widget>
If you want to enable WebSocket subscription service, initialize and display the address key address
using the English interface widget, you can use:
<sentiment-widget api-key='xxxxxxx' type-prop='address' lang-prop='en'></sentiment-widget>
After specify the api-key
subscription service, the widget will update in real-time when new records arrive.
Websocket
Endpoint: wss://stream.areix-ai.com/public/ws
subscribe msg:
{'action': 'subscribe_sentiment', 'type':<type>, 'lang':<lang>, 'key':<key>, 'domain':<domain>}
Example:
{'action': 'subscribe_sentiment', 'type':'event', 'lang':'zh', 'key':'xxxxx', 'domain':'xxxx.com'}```