Skip to content

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.

License

Notifications You must be signed in to change notification settings

vkg70/natural-language-classifier-nodejs

 
 

Repository files navigation

Natural Language Classifier Nodejs Starter Application

The IBM Watson Natural Language Classifier service applies deep learning techniques to make predictions about the best predefined classes for short sentences or phrases. The classes can trigger a corresponding action in an application, such as directing a request to a location or person, or answering a question. After training, the service returns information for texts that it hasn't seen before. The response includes the name of the top classes and confidence values.

Give it a try! Click the button below to fork into IBM DevOps Services and deploy your own copy of this application on Bluemix.

Deploy to Bluemix

Getting started

  1. You need a Bluemix account. If you don't have one, sign up. Experimental Watson Services are free to use.

  2. Download and install the Cloud-foundry CLI tool if you haven't already.

  3. 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
    
  4. Connect to Bluemix with the command line tool.

    $ cf api https://api.ng.bluemix.net
    $ cf login -u <your user ID>
  5. Create the Natural Language Classifier service in Bluemix.

    $ cf create-service natural_language_classifier free natural-language-classifier-service
  6. Update the app.js file with the classifier id in the response from the API when you create the classifier.

  7. Push your app to make it live:

    $ cf push

    For more details about developing applications that use Watson Developer Cloud services in Bluemix, see Getting started with Watson Developer Cloud and Bluemix.

  8. To get the app to respond to input, you need to train the classifier. For information about how to train with the sample data, see the tutorial.

Running locally

  1. Download and install Node.js and npm.

  2. Configure the code to connect to your service:

    1. Copy the credentials from your natural-language-classifier-service service in Bluemix. 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.

  3. 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
  4. Run the following command to start the application:

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

  6. Train the classifier, if you haven't already. See the step earlier under Getting started.

Troubleshooting

  • The main source of troubleshooting and recovery information is the Bluemix log. To view the log, run the following command:

    $ cf logs <application-name> --recent
  • For more details about the service, see the documentation for the Natural Language Classifier.

License

This sample code is licensed under Apache 2.0. Full license text is available in 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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CSS 90.6%
  • JavaScript 6.1%
  • HTML 3.3%