Name: watson-second-opinion
Owner: International Business Machines
Description: Get a second opinion on Amazon products by analyzing product reviews with Watson Discovery
Created: 2017-10-20 18:33:03.0
Updated: 2018-05-16 22:10:47.0
Pushed: 2018-05-22 16:32:06.0
Size: 6105
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
In this Code Pattern, we will create a Node.js app that takes the reviews from an online shopping website, Amazon, and feeds them into the Watson Discovery service. The reviews will be stored in a Cloudant or couchdb database. The Watson Discovery service will show the overall sentiments of the reviews. The sample application will do all the reading of reviews for you and will give an overall insight about them. The Code Pattern can be useful to developers that are looking into processing multiple documents with Watson Discovery.
When the reader has completed this Code Pattern, they will understand how to:
Create a Kubernetes cluster with either Minikube for local testing, or with IBM Bluemix Container Service to deploy in cloud. The code here is regularly tested against Kubernetes Cluster from Bluemix Container Service using Travis.
Install Docker by following the instructions here for your preferred operating system.
You would also need a Docker Registry. Docker Hub lets you create one quickly.
Create the following service:
You can use an existing IBM Cloud Kubernetes cluster
Press the above Deploy to IBM Cloud
The toolchain uses GitHub for its source control. You may be asked to authenticate the toolchain to use your account. The toolchain will clone this repo and will be used for its deployment.
Fill out the following fields.
Toolchain will fail if the namespace is taken
The IP address of your app can be found in the logs of the delivery pipeline's deploy stage.
t clone https://github.com/IBM/watson-second-opinion
watson-second-opinion/
Create the following service:
Login to Docker using your username and password for your Docker Registry.
cker login
The Node.js app will be packaged into a Docker image. This will be used by the Kubernetes Cluster.
cker build -t YOUR_DOCKERHUB_USERNAME/watson-review-analyzer:1.0 .
cker push YOUR_DOCKERHUB_USERNAME/watson-review-analyzer:1.0
Login to IBM Cloud (formerly called Bluemix). If not an IBM employee, use your IBM Cloud account username and password to login
login
If IBM employee, use –sso option and follow link for one time code, and use it to login.
login --sso
After you are logged in to IBM Cloud, you should see something like this:
endpoint: https://api.ng.bluemix.net
Time Code (Get one at https://iam-id-2.ng.bluemix.net/identity/passcode)>
enticating...
eted account IBM (d5a44c1--------1a852cef31136c)
eted resource group default
endpoint: https://api.ng.bluemix.net (API version: 2.92.0)
on: us-south
: horea.porutiu@ibm.com
unt: IBM (d5a44c1--------1a852cef31136c)
urce group: default
Next, setup kubectl to use your cluster
cs cluster-config <your-cluster-name>
Use the configuration for your cluster by exporting the environment variables - copy and paste the full line starting with:
port KUBECONFIG=
Add your Watson Discovery credentials in config.json.sample
and rename it to config.json
:
config.json
:
iscoveryUsername" : "YOUR_WATSON_DISCOVERY_USERNAME",
iscoveryPassword" : "YOUR_WATSON_DISCOVERY_PASSWORD"
Create configmap in Kubernetes for config.json
bectl create configmap watson-discovery-config --from-file=config.json
Modify watson-review-analyzer.yaml
. In the line where you specify the image name, use the docker image you just built.
Change horeaporutiu/watson-review-analyzer:2.1
to YOUR_DOCKERHUB_USERNAME/watson-review-analyzer:1.0
.
spec: containers: - image: horeaporutiu/watson-review-analyzer:2.1 imagePullPolicy: Always name: watson-reviews
Deploy the CouchDB database. This is where the reviews and Watson Discovery results will be stored.
bectl apply -f couchdb.yaml
Deploy the Watson Review Analyzer app.
bectl apply -f watson-review-analyzer.yaml
Check if your Pods are running. You should see a couchdb pod and the watson-review-analyzer pod.
bectl get pods
READY STATUS RESTARTS AGE
hdb-deployment-78c87bf5bf-2nhc2 1/1 Running 0 4d
on-reviews-deployment-859b8d454f-4zxkw 1/1 Running 0 4d
You can access the application in the browser via the Load Balancer's IP (External IP). If you don't have the Load Balancer enabled, you can access it through one of your Kubernetes' worker IP and service Node port of watson-review-analyzer.
$ kubectl get service NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE couchdb 172.21.174.52 169.xy.xyz.220 5984:32402/TCP 13d kubernetes 172.21.0.1 <none> 443/TCP 27d watson-reviews 172.21.254.246 169.48.xyz.221 80:31385/TCP 15m
If you don't have the Load Balancer and need the worker IP:
$ bx cs workers YOUR_CLUSTER_NAME OK ID Public IP Private IP Machine Type State Status Zone Version kube-dal12-cr5c30966926aa444f9c02c72d5c3e1ca5-w1 169.xy.xyz.35 10.184.120.196 b2c.16x64 normal Ready dal12 1.8.6_1506*
Go to 169.xy.xyz.221
or 169.xy.xyz.35:31385
(for clusters without a Load Balancer)
To use the app, search for the product you want the reviews to be uploaded to Watson Discovery and get its product ID (ASIN).
https://www.amazon.com/Samsung-Thinnest-Premium-Anti-Scratch-Protective/dp/
B06XZ2CM2H
/ref=cm_cr_arp_d_product_top?ie=UTF8
In this case, the product ID is B06XZ2CM2H
Go ahead and press Go
.
After Watson Discovery finishes processing all the reviews, the app should show you its General Sentiment and Top entities found.
Sample Kubernetes Yaml file that includes this package may be configured to track deployments to IBM Cloud and other Kubernetes platforms. The following information is sent to a Deployment Tracker service on each deployment:
IBM Cloud, Minikube, etc
)This data is collected from the Kubernetes Job in the sample application's yaml file. This data is used by IBM to track metrics around deployments of sample applications to IBM Cloud to measure the usefulness of our examples so that we can continuously improve the content we offer to you. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.
Please comment out/remove the Metric Kubernetes Job portion in the watson-review-analyzer.yaml
file.