|
| 1 | +# AWS Comprehend Socket |
| 2 | + |
| 3 | +- Preparation: **10 minutes** |
| 4 | +- Requirements: |
| 5 | + - Initiated Syncano project |
| 6 | + - AWS config parameters (AWS region, AWS secret access key and AWS access key id) |
| 7 | +- Sockets: |
| 8 | + - [aws-comprehend](https://syncano.io/#/sockets/aws-comprehend) |
| 9 | + |
| 10 | +### Problem to solve |
| 11 | + |
| 12 | +You placed a form online to get reviews from a product you newly released on your online platform so you can determine the: |
| 13 | + - Inference of the prevailing sentiment (POSITIVE, NEUTRAL, MIXED, NEGATIVE) about the product |
| 14 | + - Dominant languages used by customers using the product |
| 15 | + - How customers describe your product |
| 16 | + |
| 17 | +### Solution |
| 18 | + |
| 19 | +Our solution is to use [aws-comprehend](https://syncano.io/#/sockets/aws-comprehend) Syncano socket to get all the insights and answers from the product reviews gotten from the customers. |
| 20 | + |
| 21 | +### Setup |
| 22 | + |
| 23 | +#### Installing server dependencies |
| 24 | + |
| 25 | +To install `aws-comprehend` type: |
| 26 | +```sh |
| 27 | +$ syncano-cli add aws-comprehend |
| 28 | +``` |
| 29 | + |
| 30 | +During installation you will be prompted to provide: |
| 31 | + |
| 32 | +**_AWS_REGION_**: The region on which your instance will operate |
| 33 | + |
| 34 | +**_AWS_SECRET_ACCESS_KEY_**: The secret key to your aws account |
| 35 | + |
| 36 | +**_AWS_ACCESS_KEY_ID_**: The access key to your aws account |
| 37 | + |
| 38 | +**N/B:** |
| 39 | + |
| 40 | +To find AWS ACCESS_KEY_ID and AWS SECRET_ACCESS_KEY, log into your AWS account to get it. Also to get Region, search for Comprehend on your AWS Console to check supported regions and select one (e.g, us-east-1 ) |
| 41 | + |
| 42 | +Proceed to deploy `aws-comprehend` socket: |
| 43 | +```sh |
| 44 | +$ npx s deploy aws-comprehend |
| 45 | +``` |
| 46 | + |
| 47 | +#### JavaScript client setup |
| 48 | + |
| 49 | +Create an index.html file and setup a connection by initializing SyncanoClient object with instance name: |
| 50 | + |
| 51 | +```HTML |
| 52 | +<script src="https://unpkg.com/@syncano/client"></script> |
| 53 | +<script> |
| 54 | + const s = new SyncanoClient('YOUR-INSTANCE'); |
| 55 | +</script> |
| 56 | +``` |
| 57 | + |
| 58 | +> Remember to change 'YOUR-INSTANCE' into the instance attached to your project. Run `npx s` in the project folder to have it printed out in your terminal. |
| 59 | +
|
| 60 | + |
| 61 | +*To get the Dominant language used by customers using the product pass an array of user reviews to `batch-detect-dominant-language` endpoint* |
| 62 | + |
| 63 | +Example array of customer reviews: |
| 64 | +``` |
| 65 | +TextList:[ |
| 66 | + "Syncano helps the startups in our Fintech and Insurtech accelerator programs to reach product market fit faster", |
| 67 | + "Bonne réflexion bon produit" |
| 68 | + ] |
| 69 | +``` |
| 70 | +Sample script to get dominant languages used |
| 71 | +```javascript |
| 72 | +s.post('aws-comprehend/batch-detect-dominant-language', { TextList }) |
| 73 | + .then((res) => { |
| 74 | + console.log(res, 'dominant language'); |
| 75 | + }) |
| 76 | +``` |
| 77 | + |
| 78 | +*You can now group the reviews based on languages* |
| 79 | + |
| 80 | +Sample parameter to send in order to get insights on the prevailing sentiment and key phrases used by customers in reviewing the product |
| 81 | + |
| 82 | +```javascript |
| 83 | +const param = { |
| 84 | + TextList:[ |
| 85 | + "Syncano helps the startups in our Fintech and Insurtech accelerator programs to reach product market fit faster", |
| 86 | + "Good thinking good product" |
| 87 | + ], |
| 88 | + LanguageCode: "en" |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +*Sample script to get prevailing sentiment* |
| 93 | + |
| 94 | +```javascript |
| 95 | +s.post('aws-comprehend/batch-detect-sentiment', param) |
| 96 | + .then((res) => { |
| 97 | + console.log(res, 'prevailing sentiment'); |
| 98 | + }) |
| 99 | +``` |
| 100 | + |
| 101 | +*To get key phrases used by customers to describe the product replace `batch-detect-sentiment` with `batch-detect-key-phrases` from script above* |
| 102 | + |
| 103 | +Now, when you open the index.html file and look in the browser console, you will see logs to all the answers of the problem the online review aim to solve. |
0 commit comments