Skip to content

Commit

Permalink
add test for call tokenize() then untokenize()
Browse files Browse the repository at this point in the history
  • Loading branch information
System Administrator authored and System Administrator committed Sep 14, 2020
1 parent 040dbc5 commit eb09256
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class Tokenizer {
result += arr[i];
continue;
} else if (arr[i] === "." && lastIsWWW){
console.log('yes');
//console.log('yes');
nextNoSpace = true;
} else if (thisLBracket) {
result += delim;
Expand Down
18 changes: 18 additions & 0 deletions test/tokenizer-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ describe('RiTa.Tokenizer', () => {

if (typeof module !== 'undefined') require('./before');

it ('Calling tokenize then untokenize', () =>{
let sentences = [
"this is www.google.com",
"it is 'hell'"
];
let tokens = [
["this", "is", "www", ".", "google", ".", "com"],
["it", "is", "'", "hell", "'"]
];
for (i = 0; i < sentences.length; i++){
let usingTokenize = RiTa.tokenize(sentences[i]);
expect(usingTokenize).eql(tokens[i]);
let usingUntokenize = RiTa.untokenize(usingTokenize);
expect(usingUntokenize).eq(sentences[i]);
};

});

it('Should correctly call tokenize', () => {

expect(RiTa.tokenize("")).eql([""]);
Expand Down

0 comments on commit eb09256

Please sign in to comment.