forked from agrawal-d/cph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve problem name parser to handle numbers.
- Loading branch information
Showing
5 changed files
with
28 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
verbose: false, | ||
silent: true, | ||
}; |
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,21 @@ | ||
import { words_in_text } from '../utilsPure'; | ||
|
||
describe('problem name parser', () => { | ||
test('mix of latin, non latin and numbers', () => { | ||
const output = ['apple', '12345', 'mango', 'India', 'こんにちは', '7']; | ||
const input = 'apple 12345 mango India こんにちは 7'; | ||
expect(words_in_text(input)).toEqual(output); | ||
}); | ||
|
||
test('just a number', () => { | ||
const output = ['23']; | ||
const input = '23'; | ||
expect(words_in_text(input)).toEqual(output); | ||
}); | ||
|
||
test('just a word', () => { | ||
const output = ['grapes']; | ||
const input = 'grapes'; | ||
expect(words_in_text(input)).toEqual(output); | ||
}); | ||
}); |
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,4 @@ | ||
export const words_in_text = function (text: string) { | ||
const regex = /[\p{L}-]+|[0-9]+/gu; | ||
return text.match(regex); | ||
}; |