Showing
1 changed file
with
51 additions
and
45 deletions
| 1 | 1 | ||
| 2 | - var _f = [ | 2 | +var _f = [ |
| 3 | - function(string) { //을/를 구분 | 3 | + function (string) { //을/를 구분 |
| 4 | - return _hasJong(string) ? '을' : '를'; | 4 | + return _hasJong(string) ? '을' : '를'; |
| 5 | - }, | 5 | + }, |
| 6 | - function(string){ //은/는 구분 | 6 | + function (string) { //은/는 구분 |
| 7 | - return _hasJong(string) ? '은' : '는'; | 7 | + return _hasJong(string) ? '은' : '는'; |
| 8 | - }, | 8 | + }, |
| 9 | - function(string){ //이/가 구분 | 9 | + function (string) { //이/가 구분 |
| 10 | - return _hasJong(string) ? '이' : '가'; | 10 | + return _hasJong(string) ? '이' : '가'; |
| 11 | - }, | 11 | + }, |
| 12 | - function(string){ //와/과 구분 | 12 | + function (string) { //와/과 구분 |
| 13 | - return _hasJong(string) ? '과' : '와'; | 13 | + return _hasJong(string) ? '과' : '와'; |
| 14 | - } | 14 | + }, |
| 15 | - ], | 15 | + function (string) { //으로/로 구분 |
| 16 | - _formats = { | 16 | + return _hasJong(string) ? '으로' : '로'; |
| 17 | - '을/를' : _f[0], | ||
| 18 | - '을' : _f[0], | ||
| 19 | - '를' : _f[0], | ||
| 20 | - '을를' : _f[0], | ||
| 21 | - '은/는' : _f[1], | ||
| 22 | - '은' : _f[1], | ||
| 23 | - '는' : _f[1], | ||
| 24 | - '은는' : _f[1], | ||
| 25 | - '이/가' : _f[2], | ||
| 26 | - '이' : _f[2], | ||
| 27 | - '가' : _f[2], | ||
| 28 | - '이가' : _f[2], | ||
| 29 | - '와/과' : _f[3], | ||
| 30 | - '와' : _f[3], | ||
| 31 | - '과' : _f[3], | ||
| 32 | - '와과' : _f[3] | ||
| 33 | - }; | ||
| 34 | - | ||
| 35 | - function _hasJong(string){ //string의 마지막 글자가 받침을 가지는지 확인 | ||
| 36 | - string = string.charCodeAt(string.length - 1); | ||
| 37 | - return (string - 0xac00) % 28 > 0; | ||
| 38 | } | 17 | } |
| 39 | - | 18 | +], |
| 40 | - var josa = { | 19 | + _formats = { |
| 41 | - c: function(word, format){ | 20 | + '을/를': _f[0], |
| 42 | - if (typeof _formats[format] === 'undefined') throw 'Invalid format!'; | 21 | + '을': _f[0], |
| 43 | - return _formats[format](word); | 22 | + '를': _f[0], |
| 44 | - }, | 23 | + '을를': _f[0], |
| 45 | - r: function(word, format) { | 24 | + '은/는': _f[1], |
| 46 | - return word + josa.c(word, format); | 25 | + '은': _f[1], |
| 47 | - } | 26 | + '는': _f[1], |
| 27 | + '은는': _f[1], | ||
| 28 | + '이/가': _f[2], | ||
| 29 | + '이': _f[2], | ||
| 30 | + '가': _f[2], | ||
| 31 | + '이가': _f[2], | ||
| 32 | + '와/과': _f[3], | ||
| 33 | + '와': _f[3], | ||
| 34 | + '과': _f[3], | ||
| 35 | + '와과': _f[3], | ||
| 36 | + '으로': _f[4], | ||
| 37 | + '로': _f[4], | ||
| 38 | + '으로/로': _f[4] | ||
| 48 | }; | 39 | }; |
| 40 | + | ||
| 41 | +function _hasJong(string) { //string의 마지막 글자가 받침을 가지는지 확인 | ||
| 42 | + string = string.charCodeAt(string.length - 1); | ||
| 43 | + return (string - 0xac00) % 28 > 0; | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +var josa = { | ||
| 47 | + c: function (word, format) { | ||
| 48 | + if (typeof _formats[format] === 'undefined') throw 'Invalid format!'; | ||
| 49 | + return _formats[format](word); | ||
| 50 | + }, | ||
| 51 | + r: function (word, format) { | ||
| 52 | + return word + josa.c(word, format); | ||
| 53 | + } | ||
| 54 | +}; | ... | ... |
-
Please register or login to post a comment