Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change jamo lib to nested arrays with objects
- Loading branch information
Showing
5 changed files
with
102 additions
and
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,81 @@ | ||
// choseong | ||
const initialConsonants = [ | ||
"ㄱ", // 0 | ||
"ㄲ", // ㄱㄱ | ||
"ㄴ", | ||
"ㄷ", | ||
"ㄸ", // ㄷㄷ | ||
"ㄹ", // 5 | ||
"ㅁ", | ||
"ㅂ", | ||
"ㅃ", // ㅂㅂ | ||
"ㅅ", | ||
"ㅆ", // ㅅㅅ | ||
"ㅇ", | ||
"ㅈ", | ||
"ㅉ", // ㅈㅈ | ||
"ㅊ", | ||
"ㅋ", // 15 | ||
"ㅌ", | ||
"ㅍ", | ||
"ㅎ" | ||
]; | ||
|
||
// jungseong | ||
const medialVowels = [ | ||
"ㅏ", | ||
"ㅐ", | ||
"ㅑ", | ||
"ㅒ", | ||
"ㅓ", | ||
"ㅔ", | ||
"ㅕ", | ||
"ㅖ", | ||
"ㅗ", | ||
"ㅘ", // ㅗㅏ | ||
"ㅙ", // ㅗㅐ | ||
"ㅚ", | ||
"ㅛ", | ||
"ㅜ", | ||
"ㅝ", // ㅜㅓ | ||
"ㅞ", // ㅜㅔ | ||
"ㅟ", // ㅜㅣ | ||
"ㅠ", | ||
"ㅡ", | ||
"ㅢ", // ㅡㅣ | ||
"ㅣ" | ||
]; | ||
// "...what have the Romans ever done for us?" | ||
|
||
// jongseong | ||
const finalConsonants = [ | ||
null, | ||
"ㄱ", | ||
"ㄲ", // ㄱㄱ | ||
"ㄳ", // ㄱㅅ | ||
"ㄴ", | ||
"ㄵ", // ㄴㅈ | ||
"ㄶ", // ㄴㅎ | ||
"ㄷ", | ||
"ㄹ", | ||
"ㄺ", // ㄹㄱ | ||
"ㄻ", // ㄹㅁ | ||
"ㄼ", // ㄹㅂ | ||
"ㄽ", // ㄹㅅ | ||
"ㄾ", // ㄹㅌ | ||
"ㄿ", // ㄹㅍ | ||
"ㅀ", // ㄹㅎ | ||
"ㅁ", | ||
"ㅂ", | ||
"ㅄ", // ㅂㅅ | ||
"ㅅ", | ||
"ㅆ", // ㅅㅅ | ||
"ㅇ", | ||
"ㅈ", | ||
"ㅊ", | ||
"ㅋ", | ||
"ㅌ", | ||
"ㅍ", | ||
"ㅎ" | ||
module.exports = [ | ||
// choseong | ||
[ | ||
{ jamo: "ㄱ", roman: "g" }, | ||
{ jamo: "ㄲ", roman: "gg" }, | ||
{ jamo: "ㄴ", roman: "n" }, | ||
{ jamo: "ㄷ", roman: "d" }, | ||
{ jamo: "ㄸ", roman: "dd" }, | ||
{ jamo: "ㄹ", roman: "r" }, | ||
{ jamo: "ㅁ", roman: "m" }, | ||
{ jamo: "ㅂ", roman: "b" }, | ||
{ jamo: "ㅃ", roman: "bb" }, | ||
{ jamo: "ㅅ", roman: "s" }, | ||
{ jamo: "ㅆ", roman: "ss" }, | ||
{ jamo: "ㅇ", roman: "" }, | ||
{ jamo: "ㅈ", roman: "j" }, | ||
{ jamo: "ㅉ", roman: "jj" }, | ||
{ jamo: "ㅊ", roman: "ch" }, | ||
{ jamo: "ㅋ", roman: "k" }, | ||
{ jamo: "ㅌ", roman: "t" }, | ||
{ jamo: "ㅍ", roman: "p" }, | ||
{ jamo: "ㅎ", roman: "h" } | ||
], | ||
// jungseong | ||
[ | ||
{ jamo: "ㅏ", roman: "a" }, | ||
{ jamo: "ㅐ", roman: "ae" }, | ||
{ jamo: "ㅑ", roman: "yeo" }, | ||
{ jamo: "ㅒ", roman: "yae" }, | ||
{ jamo: "ㅓ", roman: "eo" }, | ||
{ jamo: "ㅔ", roman: "ye" }, | ||
{ jamo: "ㅕ", roman: "yeo" }, | ||
{ jamo: "ㅖ", roman: "ye" }, | ||
{ jamo: "ㅗ", roman: "o" }, | ||
{ jamo: "ㅘ", roman: "wa" }, | ||
{ jamo: "ㅙ", roman: "wae" }, | ||
{ jamo: "ㅚ", roman: "woe" }, | ||
{ jamo: "ㅛ", roman: "yo" }, | ||
{ jamo: "ㅜ", roman: "u" }, | ||
{ jamo: "ㅝ", roman: "wo" }, | ||
{ jamo: "ㅞ", roman: "we" }, | ||
{ jamo: "ㅟ", roman: "wi" }, | ||
{ jamo: "ㅠ", roman: "yu" }, | ||
{ jamo: "ㅡ", roman: "eu" }, | ||
{ jamo: "ㅢ", roman: "ui" }, | ||
{ jamo: "ㅣ", roman: "i" } | ||
], | ||
// jongseong | ||
[ | ||
null, | ||
{ jamo: "ㄱ", roman: "k" }, | ||
{ jamo: "ㄲ", roman: "k" }, | ||
{ jamo: "ㄳ", roman: "k" }, | ||
{ jamo: "ㄴ", roman: "n" }, | ||
{ jamo: "ㄵ", roman: "n" }, | ||
{ jamo: "ㄶ", roman: "n" }, | ||
{ jamo: "ㄷ", roman: "d" }, | ||
{ jamo: "ㄹ", roman: "l" }, | ||
{ jamo: "ㄺ", roman: "r" }, | ||
{ jamo: "ㄻ", roman: "lm" }, | ||
{ jamo: "ㄼ", roman: "lb" }, | ||
{ jamo: "ㄽ", roman: "ls" }, | ||
{ jamo: "ㄾ", roman: "lt" }, | ||
{ jamo: "ㄿ", roman: "lp" }, | ||
{ jamo: "ㅀ", roman: "lh" }, | ||
{ jamo: "ㅁ", roman: "m" }, | ||
{ jamo: "ㅂ", roman: "b" }, | ||
{ jamo: "ㅄ", roman: "bs" }, | ||
{ jamo: "ㅅ", roman: "s" }, | ||
{ jamo: "ㅆ", roman: "ss" }, | ||
{ jamo: "ㅇ", roman: "ng" }, | ||
{ jamo: "ㅈ", roman: "j" }, | ||
{ jamo: "ㅊ", roman: "ch" }, | ||
{ jamo: "ㅋ", roman: "k" }, | ||
{ jamo: "ㅌ", roman: "t" }, | ||
{ jamo: "ㅍ", roman: "p" }, | ||
{ jamo: "ㅎ", roman: "h" } | ||
] | ||
]; | ||
|
||
module.exports = { | ||
initialConsonants, | ||
medialVowels, | ||
finalConsonants | ||
}; |
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,22 +1,24 @@ | ||
const { initialConsonants, medialVowels, finalConsonants } = require("./jamo"); | ||
const [initialConsonants, medialVowels, finalConsonants] = require("./jamo"); | ||
const _ = require("lodash"); | ||
|
||
describe("Jamo dictionary", () => { | ||
test("should return zero value for lack of (null) batchim/final consonaunt", () => { | ||
test("should return zero value for lack of (null) final consonant", () => { | ||
expect(finalConsonants.indexOf(null)).toBe(0); | ||
}); | ||
|
||
test("should return value for 27 of ㅎ as batchim/final consonaunt", () => { | ||
expect(finalConsonants.indexOf("ㅎ")).toBe(27); | ||
test("should return value for 27 of ㅎ as final consonant", () => { | ||
expect(_.findIndex(finalConsonants, { jamo: "ㅎ" })).toBe(27); | ||
}); | ||
|
||
test("should return value of zero for lack of ㅏ as medial vowel", () => { | ||
expect(medialVowels.indexOf("ㅏ")).toBe(0); | ||
expect(_.findIndex(medialVowels, { jamo: "ㅏ" })).toBe(0); | ||
}); | ||
|
||
test("should return value of 20 for lack of ㅣ as medial vowel", () => { | ||
expect(medialVowels.indexOf("ㅣ")).toBe(20); | ||
expect(_.findIndex(medialVowels, { jamo: "ㅣ" })).toBe(20); | ||
}); | ||
|
||
test("should return value of 18 for lack of ㅎ as initial consonaunt", () => { | ||
expect(initialConsonants.indexOf("ㅎ")).toBe(18); | ||
test("should return value of 18 for lack of ㅎ as initial consonant", () => { | ||
expect(_.findIndex(initialConsonants, { jamo: "ㅎ" })).toBe(18); | ||
}); | ||
}); |
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