Skip to content

Commit

Permalink
test(wink-nlp-specs): ensure printed data is also tested
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayaksaxena committed May 30, 2022
1 parent cdfbcdb commit 7100382
Showing 1 changed file with 247 additions and 0 deletions.
247 changes: 247 additions & 0 deletions test/wink-nlp-specs.js
Expand Up @@ -147,7 +147,254 @@ describe( 'wink-nlp test-coverage and basic behavior', function () {
} );

it( 'should display the correct tokens & their properties', function () {
const tokens = [
'🎭',
'Mr.',
'-',
':)',
'🎉',
'🎉',
'\n',
'pappu@gmail.com',
'(',
'I.I.T.',
')',
'I.I.T',
'\'s',
'*',
'good',
'.',
'*',
'https://winkjs.org',
'#great',
'I',
'met',
'her',
'in',
'(',
'*',
'-',
'\'80s',
'-',
'*',
')',
'\'',
'and',
'/',
'or',
')',
'-',
'\'',
'cause',
'\'',
'Pappu',
'pass',
'ho',
'gaya',
'—',
'HaHaHa',
'.',
'Recognise',
'it',
'Pappu',
'(',
'pappu',
'recognise',
')',
'?',
'I',
'ca',
'n\'t',
'do',
'!',
'i',
'\'ll',
'\'ve',
'to',
'do',
'!',
'Strange',
'!',
'I.',
'K.',
'Gujral',
'who',
'am',
'I',
'?',
'🎭',
',',
'[',
'🧞',
'[',
'Dabbu',
'(',
'left',
')',
'(',
'OOV',
')',
'March',
'12',
',',
'1998',
'e-mail',
'server-less',
'F-16',
'zxcvbn',
'-',
'asfgh',
'S.K.',
'Saxena',
'.',
'Server-less',
'computing',
'is',
'awesome',
'.',
'Mr.',
'S.K.',
'Saxena',
'aaa',
'.',
'-',
'bbb',
'138375720109463900845220131105025504431',
'resources094639008452'
];

const prefixes = [
'🎭', 'Mr', '-', ':)', '🎉', '🎉', '\n', 'pa', '(', 'I.', ')',
'I.', '\'s', '*', 'go', '.', '*', 'ht', '#g', 'I', 'me', 'he',
'in', '(', '*', '-', '\'8', '-', '*', ')', '\'', 'an', '/',
'or', ')', '-', '\'', 'ca', '\'', 'Pa', 'pa', 'ho', 'ga', '—',
'Ha', '.', 'Re', 'it', 'Pa', '(', 'pa', 're', ')', '?', 'I',
'ca', 'n\'', 'do', '!', 'i', '\'l', '\'v', 'to', 'do', '!', 'St',
'!', 'I.', 'K.', 'Gu', 'wh', 'am', 'I', '?', '🎭', ',', '[',
'🧞', '[', 'Da', '(', 'le', ')', '(', 'OO', ')', 'Ma', '12',
',', '19', 'e-', 'se', 'F-', 'zx', '-', 'as', 'S.', 'Sa', '.',
'Se', 'co', 'is', 'aw', '.', 'Mr', 'S.', 'Sa', 'aa', '.', '-',
'bb', '13', 're'
];

const suffixes = [
'🎭', 'Mr.', '-', ':)', '🎉', '🎉', '\n', 'com', '(', '.T.',
')', 'I.T', '\'s', '*', 'ood', '.', '*', 'org', 'eat', 'I',
'met', 'her', 'in', '(', '*', '-', '80s', '-', '*', ')',
'\'', 'and', '/', 'or', ')', '-', '\'', 'use', '\'', 'ppu',
'ass', 'ho', 'aya', '—', 'aHa', '.', 'ise', 'it', 'ppu', '(',
'ppu', 'ise', ')', '?', 'I', 'ca', 'n\'t', 'do', '!', 'i',
'\'ll', '\'ve', 'to', 'do', '!', 'nge', '!', 'I.', 'K.', 'ral',
'who', 'am', 'I', '?', '🎭', ',', '[', '🧞', '[', 'bbu',
'(', 'eft', ')', '(', 'OOV', ')', 'rch', '12', ',', '998',
'ail', 'ess', '-16', 'vbn', '-', 'fgh', '.K.', 'ena', '.', 'ess',
'ing', 'is', 'ome', '.', 'Mr.', '.K.', 'ena', 'aaa', '.', '-',
'bbb', '431', '452'
];

const types = [
'emoji', 'word', 'punctuation', 'emoticon', 'emoji',
'emoji', 'tabCRLF', 'email', 'punctuation', 'word',
'punctuation', 'word', 'word', 'symbol', 'word',
'punctuation', 'symbol', 'url', 'hashtag', 'word',
'word', 'word', 'word', 'punctuation', 'symbol',
'punctuation', 'decade', 'punctuation', 'symbol', 'punctuation',
'punctuation', 'word', 'punctuation', 'word', 'punctuation',
'punctuation', 'punctuation', 'word', 'punctuation', 'word',
'word', 'word', 'word', 'punctuation', 'word',
'punctuation', 'word', 'word', 'word', 'punctuation',
'word', 'word', 'punctuation', 'punctuation', 'word',
'word', 'word', 'word', 'punctuation', 'word',
'word', 'word', 'word', 'word', 'punctuation',
'word', 'punctuation', 'word', 'word', 'word',
'word', 'word', 'word', 'punctuation', 'emoji',
'punctuation', 'punctuation', 'emoji', 'punctuation', 'word',
'punctuation', 'word', 'punctuation', 'punctuation', 'word',
'punctuation', 'word', 'number', 'punctuation', 'number',
'word', 'word', 'word', 'word', 'punctuation',
'word', 'word', 'word', 'punctuation', 'word',
'word', 'word', 'word', 'punctuation', 'word',
'word', 'word', 'word', 'punctuation', 'punctuation',
'word', 'number', 'word'
];

const precedingSpaces = [
'', '', '', '', ' ', '', ' ', ' ', ' ', '', '', ' ',
'', ' ', '', '', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
'', ' ', ' ', '', ' ', '', ' ', '', '', '', '', ' ',
'', '', '', ' ', ' ', ' ', ' ', ' ', ' ', '', ' ', ' ',
' ', ' ', '', ' ', '', '', ' ', ' ', '', ' ', '', ' ',
'', '', ' ', ' ', '', ' ', '', ' ', ' ', ' ', ' ', ' ',
' ', '', ' ', '', ' ', '', ' ', '', ' ', '', '', ' ',
'', '', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', '', '',
' ', '', '', '', ' ', ' ', ' ', '', ' ', '', ' ', ' ',
'', '', '', ' ', ''
];

const shapes = [
'🎭', 'Xx.', '-', ':)',
'🎉', '🎉', '\n', 'xxxx@xxxx.xxx',
'(', 'X.X.X.', ')', 'X.X.X',
'\'x', '*', 'xxxx', '.',
'*', 'xxxx://xxxx.xxx', '#xxxx', 'X',
'xxx', 'xxx', 'xx', '(',
'*', '-', '\'ddx', '-',
'*', ')', '\'', 'xxx',
'/', 'xx', ')', '-',
'\'', 'xxxx', '\'', 'Xxxxx',
'xxxx', 'xx', 'xxxx', '—',
'XxXxXx', '.', 'Xxxxx', 'xx',
'Xxxxx', '(', 'xxxx', 'xxxx',
')', '?', 'X', 'xx',
'x\'x', 'xx', '!', 'x',
'\'xx', '\'xx', 'xx', 'xx',
'!', 'Xxxxx', '!', 'X.',
'X.', 'Xxxxx', 'xxx', 'xx',
'X', '?', '🎭', ',',
'[', '🧞', '[', 'Xxxxx',
'(', 'xxxx', ')', '(',
'XXX', ')', 'Xxxxx', 'dd',
',', 'dddd', 'x-xxxx', 'xxxx-xxxx',
'X-dd', 'xxxx', '-', 'xxxx',
'X.X.', 'Xxxxx', '.', 'Xxxxx-xxxx',
'xxxx', 'xx', 'xxxx', '.',
'Xx.', 'X.X.', 'Xxxxx', 'xxx',
'.', '-', 'xxx', 'dddd',
'xxxxdddd'
];

const cases = [
'other', 'titleCase', 'other', 'other', 'other', 'other',
'other', 'other', 'other', 'upperCase', 'other', 'upperCase',
'other', 'other', 'lowerCase', 'other', 'other', 'other',
'other', 'upperCase', 'lowerCase', 'lowerCase', 'lowerCase', 'other',
'other', 'other', 'other', 'other', 'other', 'other',
'other', 'lowerCase', 'other', 'lowerCase', 'other', 'other',
'other', 'lowerCase', 'other', 'titleCase', 'lowerCase', 'lowerCase',
'lowerCase', 'other', 'other', 'other', 'titleCase', 'lowerCase',
'titleCase', 'other', 'lowerCase', 'lowerCase', 'other', 'other',
'upperCase', 'lowerCase', 'other', 'lowerCase', 'other', 'lowerCase',
'other', 'other', 'lowerCase', 'lowerCase', 'other', 'titleCase',
'other', 'upperCase', 'upperCase', 'titleCase', 'lowerCase', 'lowerCase',
'upperCase', 'other', 'other', 'other', 'other', 'other',
'other', 'titleCase', 'other', 'lowerCase', 'other', 'other',
'upperCase', 'other', 'titleCase', 'other', 'other', 'other',
'lowerCase', 'lowerCase', 'other', 'lowerCase', 'other', 'lowerCase',
'upperCase', 'titleCase', 'other', 'titleCase', 'lowerCase', 'lowerCase',
'lowerCase', 'other', 'titleCase', 'upperCase', 'titleCase', 'lowerCase',
'other', 'other', 'lowerCase', 'other', 'other'
];

var doc = nlp.readDoc( sentence );

// Test what is going to be diplayed!
expect( doc.tokens().out() ).to.deep.equal( tokens );
expect( doc.tokens().out( its.prefix ) ).to.deep.equal( prefixes );
expect( doc.tokens().out( its.suffix ) ).to.deep.equal( suffixes );
expect( doc.tokens().out( its.type ) ).to.deep.equal( types );
expect( doc.tokens().out( its.precedingSpaces ) ).to.deep.equal( precedingSpaces );
expect( doc.tokens().out( its.shape ) ).to.deep.equal( shapes );
expect( doc.tokens().out( its.case ) ).to.deep.equal( cases );
// Visual display.
doc.printTokens();
} );
Expand Down

0 comments on commit 7100382

Please sign in to comment.