백괴게임>Riemann |
imported>Hsl0 |
1번째 줄: |
1번째 줄: |
| -- 모듈 연습장입니다.
| | local p |
| local getArgs = require('모듈:Arguments').getArgs
| |
| local p = {} | |
|
| |
|
| p.josa = function(frame) | | function p.test(frame) |
| local arg = getArgs(frame) | | return frame:expandTemplate{ |
| return _josa(arg) | | title = '사용자:hsl0/연구소/2' |
| end
| | } |
| | end |
|
| |
|
| function _josa(args)
| |
| local result = {{args[3] or true, args[4] or false, args[5] or nil}, {'은', '는', '은(는)'}, {'이', '가', '이(가)'}, {'을', '를', '을(를)'}, {'으로', '로', '(으)로'}, {'과', '와', '과(와)'}, {'아', '야', '아(야)'}, {'이', '', '(이)'}}
| |
| if args[1] == '은는' then
| |
| tp = 2
| |
| elseif args[1] == '이가' then
| |
| tp = 3
| |
| elseif args[1] == '을를' then
| |
| tp = 4
| |
| elseif args[1] == '으로' then
| |
| tp = 5
| |
| elseif args[1] == '과와' then
| |
| tp = 6
| |
| elseif args[1] == '아야' then
| |
| tp = 7
| |
| elseif args[1] == '이' then
| |
| tp = 8
| |
| else tp = 1
| |
| end
| |
| local fin = mw.ustring.sub(mw.ustring.toNFD(args[2]), -1, -1)
| |
| local fnum = mw.ustring.codepoint(fin)
| |
| local code
| |
| if (fnum == 4527 or fnum == 12601) then
| |
| code = 10
| |
| elseif ((4520 <= fnum and fnum <= 4546) or (12593 <= fnum and fnum <= 12622)) then
| |
| code = 1
| |
| elseif ((4449 <= fnum and fnum <= 4469) or (12623 <= fnum and fnum <= 12643)) then
| |
| code = 2
| |
| else
| |
| code = 3
| |
| end
| |
| if tp == 5 then
| |
| if code == 1 then
| |
| josa = result[4][1]
| |
| elseif code == 2 or code == 10 then
| |
| josa = result[4][2]
| |
| else josa = result[4][3]
| |
| end
| |
| else
| |
| if code == 1 or code == 10 then
| |
| josa = result[tp][1]
| |
| elseif code == 2 then
| |
| josa = result[tp][2]
| |
| else josa = result[tp][3]
| |
| end
| |
| end
| |
| if tp == 1 or args[3] == '0' then
| |
| return josa
| |
| else
| |
| return table.concat({args[2], josa})
| |
| end
| |
| end
| |
| return p | | return p |