Skip to content
This repository was archived by the owner on Sep 22, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: watson-developer-cloud/natural-language-classifier-nodejs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.1
Choose a base ref
...
head repository: watson-developer-cloud/natural-language-classifier-nodejs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 18 commits
  • 10 files changed
  • 6 contributors

Commits on Feb 18, 2019

  1. Copy the full SHA
    96d4f5a View commit details
  2. Copy the full SHA
    9bcff18 View commit details
  3. Merge pull request #66 from watson-developer-cloud/greenkeeper/mocha-…

    …6.0.0
    
    Update mocha to the latest version 🚀
    
    Co-authored-by: null <greenkeeper[bot]@users.noreply.github.com>
    germanattanasio and greenkeeper[bot] authored Feb 18, 2019
    Copy the full SHA
    89d917c View commit details

Commits on Mar 9, 2019

  1. Copy the full SHA
    4a88c67 View commit details
  2. Copy the full SHA
    443cca5 View commit details
  3. Merge pull request #67 from watson-developer-cloud/greenkeeper/supert…

    …est-4.0.0
    
    Update supertest to the latest version 🚀
    
    Co-authored-by: null <greenkeeper[bot]@users.noreply.github.com>
    germanattanasio and greenkeeper[bot] authored Mar 9, 2019
    Copy the full SHA
    f6814b8 View commit details

Commits on May 16, 2019

  1. Copy the full SHA
    bb0adf1 View commit details

Commits on May 20, 2019

  1. Copy the full SHA
    dbe74ce View commit details

Commits on May 21, 2019

  1. Merge pull request #85 from watson-developer-cloud/terms-of-use

    feat(Layout): add Terms of Use
    jeff-arn authored May 21, 2019
    Copy the full SHA
    9d787c9 View commit details

Commits on Jun 5, 2019

  1. Bump handlebars from 4.0.13 to 4.0.14

    Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.0.13 to 4.0.14.
    - [Release notes](https://github.com/wycats/handlebars.js/releases)
    - [Changelog](https://github.com/wycats/handlebars.js/blob/v4.0.14/release-notes.md)
    - [Commits](handlebars-lang/handlebars.js@v4.0.13...v4.0.14)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Jun 5, 2019
    Copy the full SHA
    839a5bb View commit details

Commits on Jun 6, 2019

  1. Bump handlebars from 4.0.13 to 4.0.14 (#89)

    Bump handlebars from 4.0.13 to 4.0.14
    
    Co-authored-by: null <dependabot[bot]@users.noreply.github.com>
    germanattanasio and dependabot[bot] authored Jun 6, 2019
    Copy the full SHA
    cfd1164 View commit details

Commits on Jul 19, 2019

  1. Copy the full SHA
    4f015ad View commit details
  2. Merge pull request #92 from watson-developer-cloud/dep-ups

    chore(deps): Update tests and dependencies
    jeff-arn authored Jul 19, 2019
    Copy the full SHA
    d78e89b View commit details

Commits on Nov 7, 2019

  1. Copy the full SHA
    38753fd View commit details
  2. Merge pull request #94 from watson-developer-cloud/dep-ups

    🔥 Update dependencies
    germanattanasio authored Nov 7, 2019
    Copy the full SHA
    4a96a19 View commit details

Commits on Mar 13, 2020

  1. Bump acorn from 6.2.0 to 6.4.1

    Bumps [acorn](https://github.com/acornjs/acorn) from 6.2.0 to 6.4.1.
    - [Release notes](https://github.com/acornjs/acorn/releases)
    - [Commits](acornjs/acorn@6.2.0...6.4.1)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Mar 13, 2020
    Copy the full SHA
    61063eb View commit details

Commits on Mar 16, 2020

  1. Merge pull request #96 from watson-developer-cloud/dependabot/npm_and…

    …_yarn/acorn-6.4.1
    
    Bump acorn from 6.2.0 to 6.4.1
    germanattanasio authored Mar 16, 2020
    Copy the full SHA
    40c2b76 View commit details

Commits on Sep 21, 2021

  1. Update README.md

    watson-github-bot authored Sep 21, 2021
    Copy the full SHA
    086e78e View commit details
Showing with 2,619 additions and 3,479 deletions.
  1. +2 −6 .travis.yml
  2. +5 −15 README.md
  3. +11 −18 app.js
  4. +1 −7 manifest.yml
  5. +2,550 −3,403 package-lock.json
  6. +29 −27 package.json
  7. +5 −0 public/css/style.css
  8. +8 −2 test/unit/test.express.js
  9. +1 −1 views/demo.jsx
  10. +7 −0 views/layout.jsx
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: node_js
dist: trusty
sudo: required
node_js: 8
node_js: 12
script:
- npm run test

@@ -18,13 +17,10 @@ before_deploy: npm install -g bx-blue-green
deploy:
- provider: script
skip_cleanup: true
script:
- bx-blue-green-travis
script: bx-blue-green-travis
on:
branch: master
repo: watson-developer-cloud/natural-language-classifier-nodejs
- provider: script
skip_cleanup: true
script: npx semantic-release
on:
node: 8
20 changes: 5 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<h1 align="center" style="border-bottom: none;">Deprecated: this repo has been archived and will not receive further updates. It is being left in read-only mode for documentation purposes, but the code should not be considered current.</h1>
<h1 align="center" style="border-bottom: none;">🚀 Natural Language Classifier Sample Application</h1>
<h3 align="center">This Node.js app demonstrates some of the Natural Language Classifier service features.</h3>
<p align="center">
@@ -26,22 +27,21 @@ You can view a [demo](https://natural-language-classifier-demo.ng.bluemix.net/)
- Log in to your IBM Cloud account.
- Click **Create**.
- Click **Show** to view the service credentials.
- Copy the `apikey` value, or copy the `username` and `password` values if your service instance doesn't provide an `apikey`.
- Copy the `apikey` value.
- Copy the `url` value.

## Configuring the application

1. The Natural Language Classifier service must be trained before you can successfully use this application. The training data is provided in the file `training/weather_data_train.csv`.
If you have `username` and `password` credentials, train a classifier by using the following command:

```none
curl -i -u "<username>":"<password>" \
```sh
curl -i -u "apikey":"<apikey>" \
-F training_data=@training/weather_data_train.csv \
-F training_metadata="{\"language\":\"en\",\"name\":\"TutorialClassifier\"}" \
"<url>/v1/classifiers"
```
Make sure to replace `<username>`, `<password>` and `<url>`.
If you have `apikey` credentials, use the word "apikey" as your username and your `apikey` as the password.
Make sure to replace `<apikey>` and `<url>`.
After running the command, copy the value for `classifier_id`.

2. In the application folder, copy the *.env.example* file and create a file called *.env*
@@ -59,16 +59,6 @@ You can view a [demo](https://natural-language-classifier-demo.ng.bluemix.net/)
NATURAL_LANGUAGE_CLASSIFIER_URL=https://gateway.watsonplatform.net/natural-language-classifier/api
```
- If your service instance uses `username` and `password` credentials, add the `NATURAL_LANGUAGE_CLASSIFIER_USERNAME` and `NATURAL_LANGUAGE_CLASSIFIER_PASSWORD` variables to the *.env* file.
Example *.env* file that configures the `username`, `password`, and `url` for a Natural Language Classifier service instance hosted in the Sydney region:
```
NATURAL_LANGUAGE_CLASSIFIER_USERNAME=522be-7b41-ab44-dec3-g1eab2ha73c6
NATURAL_LANGUAGE_CLASSIFIER_PASSWORD=A4Z5BdGENrwu8
NATURAL_LANGUAGE_CLASSIFIER_URL=https://gateway-syd.watsonplatform.net/natural-language-classifier/api
```
8. Add the `CLASSIFIER_ID` to the previous properties
```
29 changes: 11 additions & 18 deletions app.js
Original file line number Diff line number Diff line change
@@ -17,28 +17,21 @@
const express = require('express');

const app = express();
const NaturalLanguageClassifierV1 = require('watson-developer-cloud/natural-language-classifier/v1');
const NaturalLanguageClassifierV1 = require('ibm-watson/natural-language-classifier/v1');
const { IamAuthenticator } = require('ibm-watson/auth');

// Bootstrap application settings
require('./config/express')(app);

// Create the service wrapper

let classifier;

if (process.env.NATURAL_LANGUAGE_CLASSIFIER_IAM_APIKEY && process.env.NATURAL_LANGUAGE_CLASSIFIER_IAM_APIKEY !== '') {
classifier = new NaturalLanguageClassifierV1({
url: process.env.NATURAL_LANGUAGE_CLASSIFIER_URL || '<service-url>',
iam_apikey: process.env.NATURAL_LANGUAGE_CLASSIFIER_IAM_APIKEY || '<iam_apikey>',
iam_url: process.env.ASSISTANT_IAM_URL || 'https://iam.bluemix.net/identity/token',
});
} else {
classifier = new NaturalLanguageClassifierV1({
url: process.env.NATURAL_LANGUAGE_CLASSIFIER_URL || '<service-url>',
username: process.env.NATURAL_LANGUAGE_CLASSIFIER_USERNAME || '<username>',
password: process.env.NATURAL_LANGUAGE_CLASSIFIER_PASSWORD || '<password>',
});
}
const classifier = new NaturalLanguageClassifierV1({
version: '2018-04-05',
authenticator: new IamAuthenticator({
apikey: process.env.NATURAL_LANGUAGE_CLASSIFIER_IAM_APIKEY || '<api-key>',
}),
url: process.env.NATURAL_LANGUAGE_CLASSIFIER_URL,
});

app.get('/', (req, res) => {
res.render('index', {
@@ -52,12 +45,12 @@ app.get('/', (req, res) => {
app.post('/api/classify', (req, res, next) => {
classifier.classify({
text: req.body.text,
classifier_id: process.env.CLASSIFIER_ID || '<classifier-id>',
classifierId: process.env.CLASSIFIER_ID || '<classifier-id>',
}, (err, data) => {
if (err) {
return next(err);
}
return res.json(data);
return res.json(data.result);
});
});

8 changes: 1 addition & 7 deletions manifest.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
declared-services:
my-nlc-service:
label: natural_language_classifier
plan: standard
applications:
- services:
- my-nlc-service
name: natural-language-classifier-demo
- name: natural-language-classifier-demo
command: npm start
path: .
memory: 512M
Loading