-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(WordsToNumber): Added fuzzy to fix wrong words
- Loading branch information
1 parent
cfe7d20
commit 13282a9
Showing
7 changed files
with
78 additions
and
51 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
4 changes: 2 additions & 2 deletions
4
test/wordsToNumber/fuzzy.spec.ts → test/wordsToNumber-fuzzy.spec.ts
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,32 @@ | ||
import WordsToNumber from "../src/modules/wordsToNumber"; | ||
|
||
describe("WordsToNumber", () => { | ||
it("Should works as well", () => { | ||
expect(WordsToNumber.convert("منفی سه هزار")).toEqual(-3000); | ||
expect(WordsToNumber.convert("سه هزار دویست و دوازده")).toEqual(3212); | ||
expect(WordsToNumber.convert("دوازده هزار بیست دو")).toEqual(12022); | ||
expect(WordsToNumber.convert("دوازده هزار بیست دو", { addCommas: true })).toEqual("12,022"); | ||
expect(WordsToNumber.convert("دوازده هزار و بیست و دو", { addCommas: true })).toEqual("12,022"); | ||
}); | ||
|
||
it("Ordinal words", () => { | ||
expect(WordsToNumber.convert("منفی سه هزارمین", { digits: "fa", addCommas: true })).toEqual("-۳,۰۰۰"); | ||
expect(WordsToNumber.convert("منفی سه هزارمین", { digits: "fa" })).toEqual("-۳۰۰۰"); | ||
expect(WordsToNumber.convert("منفی سه هزارمین")).toEqual(-3000); | ||
expect(WordsToNumber.convert("منفی سه هزارم")).toEqual(-3000); | ||
expect(WordsToNumber.convert("منفی سه هزارمین")).not.toEqual("-3000"); | ||
expect(String(WordsToNumber.convert("منفی سه هزارمین"))).toHaveLength(5); | ||
expect(WordsToNumber.convert("منفی سی اُم")).toEqual(-30); | ||
expect(WordsToNumber.convert("سی و سوم")).toEqual(33); | ||
}); | ||
|
||
it("Should return undefined", () => { | ||
expect(WordsToNumber.convert("", { digits: "fa", addCommas: true })).toBeUndefined(); | ||
// @ts-ignore | ||
expect(WordsToNumber.convert()).toBeUndefined(); | ||
}); | ||
|
||
it("Should works with fuzzy model", () => { | ||
expect(WordsToNumber.convert("ضد و بنچاه و دو", { fuzzy: true })).toEqual(152); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.