Skip to content

chinghuachen/natural-language-classifier-nodejs

 
 

Repository files navigation

Natural Language Classifier Demo Application

You can choose to run your app on Bluemix, or locally.

Run your app on Bluemix

  1. Create and train an instance of the Watson Natural Language Classifier.

  2. Edit the manifest.yml file and change <application-name> to something unique. The name you use determines the URL of your application. For example, <application-name>.mybluemix.net.

    applications:
    - services:
      - natural-language-classifier-service
      name: <application-name>
      command: node app.js
      path: .
      memory: 128M
    
  3. Connect to Bluemix with the command line tool.

    $ cf api https://api.ng.bluemix.net
    $ cf login -u <your user ID>
  4. Update the app.js file with the classifier id in the response from the API when you create the classifier.

  5. Push your app to make it live:

    $ cf push
  6. Your service is now live and your app is hosted at <application-name>.mybluemix.net.

Run your app locally

  1. Create and train an instance of the Watson Natural Language Classifier.

  2. Download and install Node.js and npm.

  3. Configure the code to connect to your service:

    1. Copy the credentials from your natural-language-classifier-service service. Run the following command:

      $ cf env <application-name>

      Example output:

      System-Provided:
      {
        "VCAP_SERVICES": {
      	"natural_language_classifier": [
      	  {
      		"credentials": {
      		  "password": "<password>",
      		  "url": "<url>",
      		  "username": "<username>"
      		}
      		"label": "natural-language-classifier",
      		"name": "natural-language-classifier-service",
      		"plan": "free",
      		"tags": [
      		  ... 
      		]
      	  }
      	]
        }
      }
    2. Copy username, password, and url from the credentials.

    3. Open the app.js file and paste the username, password, and url credentials for the service.

    4. Save the creds.js file.

  4. Install the Natural Language Classifier Node.js package:

    1. Change to the new directory that contains the project.
    2. Run the following command:node
    $ npm install
  5. Run the following command to start the application:

    node app.js
  6. Point your browser to http://localhost:3000.

Troubleshooting

License

This sample code is licensed under Apache 2.0. Full license text is available in LICENSE.
This sample uses jquery which is MIT license

Contributing

See CONTRIBUTING.

Open Source @ IBM

Find more open source projects on the IBM Github Page

About

See how the classifier service uses natural language to determine the intent behind your question. Ask a question about the weather, and watch as the service classifies the intent as 'temperature' or 'condition' related.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • CSS 92.0%
  • JavaScript 4.7%
  • HTML 3.3%