{"size": 1454, "ext": "js", "max_stars_repo_path": "test/unit/result/whitespace.test.js", "max_stars_repo_name": "DanielNetzer/compromise", "max_stars_repo_stars_event_min_datetime": "2019-01-08T03:13:04.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-08T03:13:04.000Z", "max_issues_repo_path": "test/unit/result/whitespace.test.js", "max_issues_repo_name": "IcaFulokoja/compromise", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/unit/result/whitespace.test.js", "max_forks_repo_name": "IcaFulokoja/compromise", "max_forks_repo_forks_event_min_datetime": "2020-01-16T23:21:39.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-16T23:21:39.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 29.08, "max_line_length": 79, "alphanum_fraction": 0.5818431912}
var test = require('tape');
var nlp = require('../lib/nlp');

test('sanity-check case:', function(t) {
  var m = nlp('john is cool. he is nice');
  m.whitespace.before('  ');
  t.equal(m.out('text'), '  john is cool.  he is nice');

  m = nlp('john is cool. he is nice');
  m.whitespace.after('    ');
  t.equal(m.out('text'), 'john is cool.     he is nice    ');

  m = nlp('so john smith is cool.');
  m.people().whitespace.before('  ');
  m.people().whitespace.after('  ');
  t.equal(m.out('text'), 'so  john smith   is cool.');

  t.end();
});

test('slashes-as-whitespace:', function(t) {
  var doc = nlp('john is cool/fun');
  t.equal(doc.terms().length, 4, '4 terms');
  t.equal(doc.has('cool'), true, 'has cool');
  t.equal(doc.has('fun'), true, 'has fun');
  t.equal(doc.out('text'), 'john is cool/fun', 'slash in output');
  t.end();
});

test('normalized whitespace', function(t) {
  var doc = nlp(`It doesn't matter`);
  doc.normalize({
    contractions: false
  });
  t.equal(doc.text(), `it doesn't matter`, 'normalized contractionwhitespace');
  t.end();
});

test('punctuation-whitespace-mixing', function(t) {
  let doc = nlp(`we released, "Square Up".`);
  let arr = doc.terms().map(obj => obj.text());
  t.deepEqual(arr, ['we', ' released,', ' "Square', ' Up".'], 'punctuation 1');

  doc = nlp('you said ... ?');
  arr = doc.terms().map(obj => obj.text());
  t.deepEqual(arr, ['you', ' said ... ?'], 'punctuation 2');

  t.end();
});
