-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from hadynz/stemming
Fix suggestion menu display. Made highlighting faster
- Loading branch information
Showing
7 changed files
with
71 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { tokenize } from './utils'; | ||
|
||
describe('tokenize', () => { | ||
const dataSet = [ | ||
{ | ||
sentence: 'The quick brown fox jumps over the lazy dog.', | ||
expected: ['quick', 'brown', 'fox', 'jump', 'lazi', 'dog'], | ||
}, | ||
{ | ||
sentence: 'GitHub Forks', | ||
expected: ['github', 'fork'], | ||
}, | ||
{ | ||
sentence: 'John Doe', | ||
expected: ['john', 'doe'], | ||
}, | ||
{ | ||
sentence: 'Approximate Inference', | ||
expected: ['approxim', 'infer'], | ||
}, | ||
]; | ||
|
||
dataSet.forEach(({ sentence, expected }) => { | ||
it(`Tokenizes and removes stop words ("${sentence}", [${expected}]`, () => { | ||
const tokens = tokenize(sentence); | ||
expect(tokens).toEqual(expected); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import natural from 'natural'; | ||
|
||
export const tokenize = (text: string): string[] => { | ||
return natural.PorterStemmer.tokenizeAndStem(text); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters