<commit_before>// Copyright 2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

var analyzeExample = require('../../language/analyze');

describe('language:analyze', function () {
  it('should analyze sentiment in text', function (done) {
    analyzeExample.main(
      'sentiment',
      'This gazinga pin is bad and it should feel bad',
      function (err, result) {
        assert(!err);
        assert(result);
        assert(result.documentSentiment);
        assert(result.documentSentiment.polarity < 0);
        done();
      }
    );
  });
  it('should analyze entities in text', function (done) {
    analyzeExample.main(
      'entities',
      '<NAME> is the author of a book called <NAME>',
      function (err, result) {
        assert(!err);
        assert(result);
        assert(result.entities && result.entities.length);
        assert(result.entities[0].name === '<NAME>');
        assert(result.entities[0].type === 'PERSON');
        done();
      }
    );
  });
  it('should analyze syntax in text', function (done) {
    analyzeExample.main(
      'syntax',
      'Betty bought a bit of bitter butter. But she said, "This butter\'s ' +
      'bitter! If I put it in my batter, it will make my batter bitter. If I ' +
      'buy some better butter - better than this bitter butter - it will ' +
      'make my batter better."',
      function (err, result) {
        assert(!err);
        assert(result);
        assert(result.sentences && result.sentences.length);
        assert(result.tokens && result.tokens.length > 5);
        done();
      }
    );
  });
});<commit_msg>* Refactored Pub/Sub samples into nice command-line programs, like the new Cloud Storage samples (#164)<commit_after>// Copyright 2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

var analyzeExample = require('../../language/analyze');

describe('language:analyze', function () {
  it('should analyze sentiment in text', function (done) {
    analyzeExample.main(
      'sentiment',
      'This gazinga pin is bad and it should feel bad',
      function (err, result) {
        assert.ifError(err);
        assert(result);
        assert(result.documentSentiment);
        assert(result.documentSentiment.polarity < 0);
        done();
      }
    );
  });
  it('should analyze entities in text', function (done) {
    analyzeExample.main(
      'entities',
      '<NAME> is the author of a book called <NAME>',
      function (err, result) {
        assert.ifError(err);
        assert(result);
        assert(result.entities && result.entities.length);
        assert(result.entities[0].name === '<NAME>');
        assert(result.entities[0].type === 'PERSON');
        done();
      }
    );
  });
  it('should analyze syntax in text', function (done) {
    analyzeExample.main(
      'syntax',
      'Betty bought a bit of bitter butter. But she said, "This butter\'s ' +
      'bitter! If I put it in my batter, it will make my batter bitter. If I ' +
      'buy some better butter - better than this bitter butter - it will ' +
      'make my batter better."',
      function (err, result) {
        assert.ifError(err);
        assert(result);
        assert(result.sentences && result.sentences.length);
        assert(result.tokens && result.tokens.length > 5);
        done();
      }
    );
  });
});
{'fraction_non_alphanumeric': 0.1255983587873262, 'fraction_numerical': 0.006154547526783679, 'mean_word_length': 2.6936026936026938, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4549593', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1195, 'n_words': 436}