-
Notifications
You must be signed in to change notification settings - Fork 0
/
자동분석봇 ver 0.4.0.js
1240 lines (1194 loc) · 69.9 KB
/
자동분석봇 ver 0.4.0.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
자동분석 ver 0.4.0
하나하나 형태소파일을 만든다(어미는 무시)
거기 안에 대응되는 형태소를 집어넣는다
ex) 뿌리 -> 가위,ㅁㅇㄹ 뭐 이렇게
각각의 형태소에서 무작위로 추출하여 응답한다
*/
const sdcard = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
const Find = {};
const P = {};
const AI = {};
const DB = {};
/*DB 객체에 포함된 함수들 정의*/
DB.createDir = function() { //채팅이 저장될 폴더를 생성하는 함수
var folder = new java.io.File(sdcard + "/형태소분리/"); //파일 인스턴스 생성
folder.mkdirs(); //폴더 생성. 상위 폴더가 없으면, 상위 폴더도 생성.
};
DB.saveData = function(name, msg) { //파일에 내용을 저장하는 함수
try {
var file = new java.io.File(sdcard + "/형태소분리/" + name + ".txt");
var fos = new java.io.FileOutputStream(file);
var str = new java.lang.String(msg);
fos.write(str.getBytes());
fos.close();
} catch (e) {
Log.debug(e + " At:" + e.lineNumber);
}
};
DB.readData = function(name) { //파일에 저장된 내용을 불러오는 함수
try {
var file = new java.io.File(sdcard + "/형태소분리/" + name + ".txt");
if (!file.exists()) return null; //파일이 없으면 null 반환
var fis = new java.io.FileInputStream(file);
var isr = new java.io.InputStreamReader(fis);
var br = new java.io.BufferedReader(isr);
var str = br.readLine();
var line = "";
while ((line = br.readLine()) != null) {
str += "\n" + line;
}
fis.close();
isr.close();
br.close();
return str;
} catch (e) {
Log.debug(e + " At:" + e.lineNumber);
}
};
{ //어미배열들
var 종결어미 = Array( //종결어미 808개 국립국어원 발췌
'거늘','거니','거니와','거던','거드면','거든','거들랑','거라','건','건대','건마는','게','게끔','게나','게시리','고','고는',
'고도','고말고','고서','고야','고자','고저','곤','관데','구나','구려','구료','구만','구먼','구면','군','기','기로','기로니',
'기로서','기로서니','기로선들','기에','길래','께','나','나니','나마','나이까','나이다','남','냐','냐고','너라','네','노니',
'노라','노라고','노라니','노라니까','노라면','뇨','누','누나','누먼','느냐','느냐고,','느뇨','느니','느니라','느니만','느니만치',
'느니만큼','느라','느라고','느라니','느라면','는','는가','는감','는걸','는고','는구나','는구려','는구료','는구만','는구먼',
'는구면','는군','는궈니','는다','는다고','는다나','는다네','는다느니','는다니','는다니까','는다더라','는다마는','는다만','는다며',
'는다면','는다면서','는다손','는다오','는다지','는단다','는담','는답니까','는답니다','는답시고','는대','는대요','는댄다','는데',
'는뎁쇼','는도다','는바','는지','는지고','는지라','늬라고','니','니까','니까느루','니까는','니깐','니라','니만치','니만큼','다', //다는 그냥 통과
'다가','다가는','다간','다고','다나','다네','다느니','다니','다니까','다더라','다마는','다마다','다만','다며','다면','다면서',
'다손','다시피','다오','다지','단','단다','담','답니까','답니다','답시고','대','대요','댄다','더구나','더구려','더구료','더구만',
'더구먼','더구면','더군','더냐','더뇨','더니','더니라','더니마는','더니만','더니이까','더니이다','더라','더라나','더라니',
'더라니까','더라도','더라며','더라면','더라면서','더라손','더라지','더람','더이까','더이다','던','던가','던감','던걸','던고',
'던데','던들','던바','던지','데','데요','도다','도록','되','드구나','드구료','드구면','드군','드냐','드니','드니라','드라',
'드라도','드라','드라도','드라면','드래도','든','든가','든걸','든고','든데','든들','든지','듯','듯이','디','라','라고','라구',
'라나','라네','라느니','라니','라니까','라도','라며','라면','라면서','라서','라손','라야','라야만','라오','라지','락','란다',
'람','랍니까','랍니다','랍시고','래','래요','랴','러','러니','러니라','러니이까','러니이다','러라','러이까','러이다','런가',
'런들','려','려거든','려고','려나','려니','려니와','려든','려마','려면','려무나','련','련마는','련만','렴','렵니까','렵니다',
'렷다','로고','로고나','로구나','로구려','로구료','로구만','로구먼','로구면','로군','로다','로되','로라','로서니','로세','리',
'리까','리니','리니라','리다','리라','리로다','리만치','리만큼','리오','마','매','며','면','면서','므로','사','사오니까',
'사오리까','사오리다','사오리이까','사오리이다','사오이다','사옵나이까','사옵나이다','사옵니까','사옵니다','사옵디까',
'사옵디다','사와','사외다','사이다','세','세나','세요','셔요','소','소다','소서','소이까','소이다','쇠다','습네','습늰다',
'습니까','습니다','습디까','습디다','습딘다','습죠','습지요','시라','시압','시어요','십사','십시다','십시오','아','아다',
'아다가','아도','아라','아라우','아서','아야','아야만','아야지','아요','아지이다','았자','야','야만','야지','어','어다',
'어다가','어도','어라','어서','어야','어야만','어야지','어야지','어요','어지이다','언마는','언만','언정','에라','에요','여',
'여다','여다가','여도','여라','여서','여야','여야만','여야지','여요','여지이다','연만','였자','오','오니까','오리까','오리다',
'오리이까','오리이다','오이까','오이다','올습니다','올시다','옵나이까','옵나이다','옵니까','옵니다','옵디까','옵디다','옵소서',
'와','외다','요','우','으께','으나','으나마','으냐','으냐고','으냐고','으뇨','으니','으니까','으니까느루','으니까는','으니깐',
'으니라','으니라고','으니만치','으니만큼','으되','으라','으라고','으라나','으라느니','으라니까','으라며','으라면서','으라손',
'으락','으란','으람','으랴','으랴','으러','으려','으려거든','으려고','으려나','으려니','으려니와','으려든','으려마','으려면',
'으려무나','으련','으련마는','으련만','으렴','으렵니까','으렵니다','으렷다','으리','으리까','으리니','으리니라','으리다',
'으리라','으리로다','으리만치','으리만큼','으리오','으마','으매','으며','으면','으면서','으므로','으사','으사이다','으세',
'으세요','으셔요','으소서','으시라','으시압','으시어요','으십사','으십시다','으십시오','으오','으오니까','으오리까',
'으오리다','으오리이까','으오리이다','으오이다','으옵','으옵나이까','으옵나이다','으옵니까','으옵니다','으옵디까','으옵디다',
'으옵소서','으와','으외다','으우','으이','은','은가','은감','은걸','은고','은데','은뎁쇼','은들','은바','은즉',
'은즉슨','은지','은지고','은지라','을','을거나','을걸','을게','을까','을깝쇼','을께','을꼬','을는지','을데라니','을라','을라고',
'을라치면','을락','을래','을러니','을러라','을런가','을런고','을런지','을레','을레라','을려고','을망정','을밖에','을뿐더러',
'을사','을새','을세라','을세말이지','을소냐','을손가','을수록','을시','을시고','을싸록','을쏘냐','을쏜가','을이만큼','을작시면',
'을지','을지나','을지니','을지니라','을지라','을지라도','을지로다','을지며','을지어다','을지언정','을진대','을진대는','을진댄',
'을진저','음','음세','음에랴','읍늰다','읍니까','읍니다','읍디까','읍디다','읍딘다','읍쇼','읍시다','읍시사','읍시오','읍죠',
'읍지요','의','이','자','자고','자구','자꾸나','자느니','자니까','자마자','자며','자면','자면서','자손','죠','지','지마는',
'지만','지만서도','지요' /*여기부터는 필요에 따라 추가*/,'져'
,'넹'
);
var 부분종결어미ㄴ = Array(
/*'ㄴ*',*/'ㄴ가','ㄴ감','ㄴ걸','ㄴ고','ㄴ다','ㄴ다고','ㄴ다나','ㄴ다네','ㄴ다느니','ㄴ다니','ㄴ다니까','ㄴ다더라','ㄴ다마는',
'ㄴ다만','ㄴ다며','ㄴ다면','ㄴ다면서','ㄴ다손','ㄴ다오','ㄴ다지','ㄴ단다','ㄴ담','ㄴ답니까','ㄴ답니다','ㄴ답시고','ㄴ대',
'ㄴ대요','ㄴ댄다','ㄴ데','ㄴ뎁쇼','ㄴ들','ㄴ바','ㄴ즉','ㄴ즉슨','ㄴ지','ㄴ지고','ㄴ지라'
)
var 부분종결어미ㄹ = Array(
/*'ㄹ',*/'ㄹ가','ㄹ거나','ㄹ걸','ㄹ게','ㄹ고','ㄹ까','ㄹ깝쇼','ㄹ꺼나','ㄹ께','ㄹ꼬','ㄹ꾸','ㄹ는지','ㄹ데라니','ㄹ라','ㄹ라고',
'ㄹ라면','ㄹ라치면','ㄹ락','ㄹ래','ㄹ랴고','ㄹ러니','ㄹ러라','ㄹ런가','ㄹ런고','ㄹ런지','ㄹ레','ㄹ레라','ㄹ려고','ㄹ려면',
'ㄹ려야','ㄹ망정','ㄹ밖에','ㄹ뿐더러','ㄹ사','ㄹ사록','ㄹ새','ㄹ세','ㄹ세라','ㄹ세말이지','ㄹ손가','ㄹ수록','ㄹ시','ㄹ시고',
'ㄹ쏘냐','ㄹ쏜가','ㄹ이만큼','ㄹ작시면','ㄹ지','ㄹ지나','ㄹ지니','ㄹ지니라','ㄹ지라','ㄹ지라도','ㄹ지로다','ㄹ지며','ㄹ지어다',
'ㄹ지언정','ㄹ진대','ㄹ진대는','ㄹ진댄','ㄹ진저'
)
var 부분종결어미ㅁ = Array(
/*'ㅁ',*/'ㅁ마','ㅁ세','ㅁ에랴'
)
var 부분종결어미ㅂ = Array(
'ㅂ네','ㅂ늰다','ㅂ니까','ㅂ니다','ㅂ디까','ㅂ디다','ㅂ딘다','ㅂ쇼','ㅂ시다','ㅂ시사','ㅂ시오','ㅂ죠','ㅂ지요'
)
var 선어말어미 = Array(
'겠','는','더','리','사오','사옵시','삽','시','았','았었','었','었었',
'였','였었','오','옵','옵시','으리','으오','으옵','으옵시','으시','자오','자옵시','잡'
)
var 부분선어말어미 = Array( //쨋든 씀
'ㄴ'
)
var 부분종결어미 = new Array;
부분종결어미 = 부분종결어미.concat(부분종결어미ㄴ,부분종결어미ㄹ,부분종결어미ㅁ,부분종결어미ㅂ);
}
{ //어간배열들
var ㄹ어간 = Array(
'갸울다','겉여물다','꺄울다','동글다','둥글다','승겁들다','야물다','여물다','우글다','가늘다','가늘디가늘다','가로걸다','가로들다','가로물다','가로썰다','가로흔들다','가말다','가멸다',
'가물다','각불불다','갈다','갈마들다','갈아들다','감겨들다','감돌다','감돌아들다','감빨다','감싸고돌다','감싸들다','감쳐돌다','감쳐물다','감풀다','개개빌다','개암들다','거닐다','거들다',
'거멀다','거미치밀다','거칠다','건들다','건몰다','걷몰다','걷어들다','걸다','걸달다','걸량걸다','걸려들다','검기울다','겉놀다','겉돌다','겉몰다','게걸들다','게들다','겯고틀다','겹깔다',
'곁달다','곁들다','계면돌다','고부라들다','고뿔들다','곡걸다','곧추들다','골다','골병들다','곱걸다','곱나들다','곱들다','곱아들다','공돌다','공들다','괄다','광달다','괠다','괴어들다',
'구부러들다','구질다','굴다','굴러들다','굼닐다','굽이돌다','궁굴다','궁글다','궁떨다','궁상떨다','그슬다','그을다','극성떨다','글다','기나길다','기승떨다','기어들다','기울다','길다',
'길동글다','길둥글다','길들다','길디길다','깃들다','까불다','깔다','깨뜰다','깨물다','꺼둘다','꺼들다','꺼불다','껴들다','껴붙들다','꼬나들다','꼬나물다','꼬부라들다','꼴다','꼽들다',
'꽃일다','꾀어들다','꾸부러들다','꿰들다','끄들다','끄을다','끌다','끌려들다','끝빨다','끼고돌다','끼어들다','끼울다','나굴다','나날다','나닐다','나돌다','나뒹굴다','나들다','나발다',
'나체밀다','날다','날아돌다','날아들다','남아돌다','남의집살다','낯설다','낯알다','내걸다','내끌다','내달다','내들다','내떨다','내려깔다','내리깔다','내리다물다','내리뒹굴다','내리몰다',
'내리밀다','내리쓸다','내몰다','내밀다','내불다','내흔들다','널다','넓둥글다','넘나들다','넘노닐다','넘놀다','넘늘다','노닐다','노망들다','녹슬다','녹쓸다','녹아들다','논풀다','놀다',
'놀들다','놉살다','농들다','누그러들다','눈길다','눈멀다','눌러살다','느물다','늑놀다','늘다','늘줄다','능놀다','늦들다','다가들다','다디달다','다물다','다부닐다','닥쳐들다','닫아걸다',
'달다','달디달다','달려들다','대들다','더불다','덕거칠다','덜다','덤거칠다','덤벼들다','덧거칠다','덧걸다','덧깔다','덧널다','덧달다','덧들다','덧얼다','덩거칠다','덩달다','덮쳐들다',
'데거칠다','데밀다','데알다','도닐다','돌다','돌아들다','되갈다','되걸다','되깔다','되돌다','되돌아들다','되들다','되말려들다','되몰다','되밀다','되살다','되틀다','되팔다','되풀다',
'되흘러들다','뒤굴다','뒤까불다','뒤놀다','뒤돌다','뒤떠들다','뒤떨다','뒤말다','뒤몰다','뒤틀다','뒤헝클다','뒤흔들다','뒵들다','뒷전놀다','뒹굴다','드나들다','드난살다','드놀다',
'드물다','드밀다','들까불다','들놀다','들다','들떠들다','들몰다','들이끌다','들이떨다','들이몰다','들이밀다','들이불다','들이빨다','들이울다','디밀다','딩굴다','떠놀다','떠다밀다',
'떠돌다','떠들다','떠밀다','떠받들다','떨다','떼걸다','떼다밀다','떼밀다','뛰놀다','뛰어놀다','뛰어들다','뜀들다','뜰다','막걸다','막놀다','막몰다','막벌다','막살다','만들다','말다',
'말려들다','망글다','맞걸다','맞다물다','맞대들다','맞돌다','맞들다','맞물다','맞밀다','맞불다','맞붙들다','매달다','맴돌다','머나멀다','머물다','먹고살다','먹혀들다','먼눈팔다',
'멀다','멋들다','멍들다','모아들다','모여들다','모질다','목매달다','목새돌다','몰다','몰려들다','몰밀다','몰아들다','못살다','몽글다','무솔다','무슬다','무질다','묶어치밀다',
'물다','물들다','물밀다','물설다','밀다','밀려들다','밀몰다','밑돌다','밑들다','받들다','밤들다','밭팔다','배돌다','배뚤다','배어들다','배틀다','버물다','번갈다','번갈아들다','벋놀다',
'벌다','벗걸다','벙글다','베돌다','베풀다','병들다','보풀다','볼달다','볼물다','봉죽들다','부닐다','부풀다','불다','붓날다','붓들다','붙닐다','붙들다','붙어살다','붚달다','비껴들다',
'비뚤다','비틀다','빌다','빗들다','빗물다','빗쓸다','빠져들다','빨다','빼뚤다','빼물다','뻬들다','뼈들다','뼈물다','삐뚤다','사고팔다','사그라들다','사레들다','사려물다','사리물다',
'삭갈다','삯팔다','산들다','산코골다','살다','새들다','새살떨다','새실떨다','서둘다','서툴다','선들다','설다','성글다','성풀다','셈들다','소용돌다','손들다','솔다','수그러들다',
'수떨다','수발들다','숨어들다','쉬슬다','스며들다','슬다','시들다','시설떨다','시중들다','실다','심들다','싸고돌다','싸돌다','쌀팔다','썰다','쏠다','쓸까슬다','쓸다','아물다',
'악다물다','악물다','안돌다','안잠살다','안틀다','알다','앙다물다','앞들다','애달다','앵돌다','어긋물다','어물다','어질다','얹혀살다','얼다','얼레살풀다','얼부풀다','얼어들다','엄살떨다',
'엇갈다','엇걸다','엇날다','엇돌다','엇물다','엉겨들다','엉켜돌다','엉켜들다','엉클다','엎어말다','에돌다','역성들다','연달다','연들다','열다','영글다','영돌다','영이돌다','옆들다',
'오그라들다','오므라들다','옥갈다','옥깨물다','옥다물다','옥물다','옭걸다','옭혀들다','옴츠러들다','옹글다','옹다물다','외돌다','외딸다','외와들다','외틀다','우그러들다','우닐다',
'우럴다','우를빌다','우무러들다','우므러들다','욱여들다','운달다','울다','울려들다','움츠러들다','웃돌다','웅글다','위들다','윽다물다','윽물다','은결들다','이끌다','이울다','이음달다',
'일다','일울다','잇달다','자디잘다','자랍들다','자발떨다','자지러들다','자처울다','잔질다','잗갈다','잗널다','잗달다','잘다','잘살다','잠들다','잡아끌다','잡아들다','장가들다','장돌다',
'잦아들다','재롱떨다','저물다','저믈다','절다','점글다','접어들다','정들다','젖빌다','조라떨다','조아팔다','조여들다','조잡들다','조접들다','졸다','졸들다','졸아들다','좨들다','죄어들다',
'주릅들다','주접떨다','줄다','줄달다','줄어들다','줌벌다','중동풀다','줴살다','줴흔들다','쥐어틀다','쥐어흔들다','쥐여살다','지르물다','지리물다','질다','짓까불다','짓깔다','짓깨물다',
'짓널다','짓떠들다','짓물다','짜들다','쩔다','쪼그라들다','쪼크라들다','쭈그러들다','쭈크러들다','찌들다','차질다','찾아들다','처걸다','철들다','쳐들다','초들다','총걸다','추켜들다',
'치돌다','치들다','치뜰다','치몰다','치밀다','치받들다','치불다','치쓸다','치켜들다','타들다','털다','통돌다','통밀다','통털다','통틀다','틀다','파고들다','판들다','판설다','팔다',
'편들다','편역들다','푸돌다','풀다','풀돌다','하리놀다','하리들다','한눈팔다','허겁떨다','허물다','헐다','헛돌다','헛들다','헛살다','헛코골다','헝클다','홈빨다','황들다','후리쓸다',
'휘날다','휘놀다','휘돌다','휘둥글다','휘말다','휘몰다','휘불다','휘어들다','휩쓸다','흐놀다','흔들다','흘러들다','흠빨다','흥글방망이놀다','흩날다','힘들다','힘빼물다'
)
var ㅡ어간 = Array( // ㅡ다 606개 국립국어원 발췌
'그르다','목마르다','크다','가냘프다','가라뜨다','가로쓰다','가로지르다','가르다','가물쓰다','가쁘다','가새지르다','가파르다','간거르다','간고르다','간지르다','갈겨쓰다','감노르다',
'감쪼으다','감파르다','갑자르다','강마르다','강파르다','갖추쓰다','개르다','개으르다','거들뜨다','거르다','거스르다','거우르다','거울르다','건너지르다','건느다','걷어지르다','걷지르다',
'걸뜨다','검누르다','검쓰다','검푸르다','검흐르다','것지르다','겉마르다','겉바르다','게르다','게으르다','겨우르다','겯지르다','겹지르다','곁따르다','곁지르다','고달프다','고르다','고프다',
'고함지르다','곧바르다','곧아오르다','곧추뜨다','곯마르다','곰뱅이트다','공그르다','공뜨다','관디목지르다','광뜨다','괴어오르다','구기박지르다','구기지르다','구르다','구박지르다',
'구쁘다','구스르다','구슬프다','굴르다','굼뜨다','궤찌르다','그느다','그느르다','그러모으다','그스르다','그으르다','글르다','긁어모으다','기두르다','기르다','기쁘다','기어오르다',
'까무느다','까부르다','까지르다','깎아지르다','깔뜨다','깡마르다','꺼두르다','꼬느다,','꼬실르다','꼰지르다','꼼바르다','꾀바르다','꾀발르다','꾀쓰다','꿰지르다','꿰찌르다','끄다',
'끄두르다','끄르다','끄스르다','끄시르다','끄지르다','끄질르다','끌어모으다','끓어오르다','끝마무르다','나뜨다','나르다','나쁘다','나오르다','날려쓰다','날르다','날아오르다','남다르다',
'남모르다','남유다르다','낯모르다','내두르다','내려쓰다','내리구르다','내리누르다','내리뜨다','내리쓰다','내리지르다','내리흐르다','내립뜨다','내박지르다','내지르다','내찌르다','내휘두르다',
'냅뜨다','너르다','너르디너르다','넘겨쓰다','넘쳐흐르다','노느다','노르다','농트다','높푸르다','놓아기르다','누르다','누르디누르다','눈뜨다','눈트다','눌러쓰다','눌르다','뉘쁘다','뉘우쁘다',
'늠그다','능그다','늦치르다','다가쓰다','다그다','다다르다','다르다','다지르다','달뜨다','달아오르다','담그다','당겨쓰다','당그다','대지르다','대질르다','더느다','덧바르다','덧쓰다',
'덮누르다','덮어쓰다','덮쳐누르다','데바쁘다','도두뜨다','도뜨다','도르다','도스르다','도슬르다','돈바르다','돌려쓰다','돔바르다','동뜨다','동트다','되뜨다','되부르다','되쓰다',
'되오르다','되조르다','되지르다','될성부르다','두르다','두스르다','둘러쓰다','둘르다','뒤구르다','뒤굴르다','뒤까부르다','뒤따르다','뒤뜨다','뒤무르다','뒤바르다','뒤스르다','뒤슬르다',
'뒤쓰다','뒤어쓰다','뒤지르다','뒤집어쓰다','뒵쓰다','드다르다','드바쁘다','들까부르다','들뜨다','들르다','들문지르다','들쓰다','들이대지르다','들이마르다','들이조르다','들이지르다',
'들이찌르다','따르다','때오르다','떠다박지르다','떠박지르다','떠오르다','떼쓰다','똑바르다','뛰어오르다','뜨다','뜸뜨다','마르다','마무르다','막거르다','막다르다','막쓰다',
'막지르다','맛다르다','맛바르다','망거지르다','망그지르다','맞찌르다','매고르다','머무르다','먹물뜨다','멋모르다','메뜨다','메마르다','멥뜨다','멱찌르다','면바르다','모가쓰다',
'모들뜨다','모뜨다','모르다','모아쓰다','모으다','못쓰다','무느다','무르다','무릅쓰다','무지르다','무질르다','무찌르다','문지르다','문질르다','문흐다','물르다','물수제비뜨다',
'물어박지르다','물오르다','뭉그지르다','미쁘다','바라오르다','바르다','바쁘다','바수지르다','박지르다','반배부르다','반지빠르다','받아쓰다','배고프다','배다르다','배부르다','버무르다',
'벅차오르다','벋지르다','벋쳐오르다','벌쓰다','벗트다','벼르다','변쓰다','별다르다','별르다','볕바르다','복부르다','본뜨다','볼줴지르다','볼쥐어지르다','부따르다','부르다','부르트다',
'부릅뜨다','부수지르다','부어오르다','부프다','분지르다','불사르다','불타오르다','붉누르다','붓따르다','붙따르다','비껴쓰다','빗뜨다','빠르다','빨르다','뺏마르다','뻗지르다','뻗쳐오르다',
'뼈아프다','사뜨다','사로잠그다','사르다','사작바르다','살르다','살지르다','샅바지르다','새암바르다','색다르다','샘바르다','서글프다','서두르다','서둘르다','서뿌르다','서투르다','섣부르다',
'설뜨다','설마르다','성마르다','세로쓰다','세상모르다','손쓰다','솝뜨다','솟아오르다','순지르다','슬프다','시까스르다','시들마르다','시쁘다','시지르다','시푸르다','싯까스르다','싸지르다',
'싹트다','쌈지뜨다','쌍심지오르다','쏘지르다','쏟지르다','쓰까스르다','쓰다','쓰디쓰다','쓸까스르다','씨까스르다','아우르다','아프다','악바르다','악쓰다','안슬프다','안추르다','암지르다',
'앞다그다','앞지르다','애달프다','애바르다','애바쁘다','애쓰다','약바르다','약빠르다','약빨르다','약사바르다','약삭빠르다','약석바르다','양지바르다','얕푸르다','어르다','어무르다',
'어버리크다','어설프다','어여쁘다','어우르다','어정뜨다','어지르다','어지빠르다','어짓바르다','억누르다','얼뜨다','얼마르다','엇뜨다','엇지르다','엊빠르다','엎누르다','엎어누르다',
'엎지르다','에너르다','에두르다','역바르다','역빠르다','연푸르다','열뜨다','엷푸르다','옅푸르다','옆찌르다','예두르다','예바르다','예쁘다','예쁘디예쁘다','오르다','오야스다','옥지르다',
'올바르다','옻오르다','왕청뜨다','외따르다','용쓰다','우러르다','욱박지르다','욱지르다','울그다','움트다','유다르다','으끄지르다','으르다','윽다지르다','윽박지르다','윽벼르다','을프다',
'이르다','이쁘다','이쁘디이쁘다','일르다','일서두르다','입바르다','입빠르다','잇따르다','자라오르다','자르다','자물쓰다','자므다','자추르다','잔지르다','잠그다','잦추르다','재바르다',
'재빠르다','재장바르다','재재바르다','저즈르다','저지르다','저질르다','적바르다','전주르다','접지르다','정바르다','젖어오르다','조르다','졸르다','좌뜨다','주무르다','죽질르다','줴바르다',
'줴지르다','쥐어바르다','쥐어지르다','지르누르다','지르다','지릅뜨다','지지누르다','지지르다','진무르다','집어쓰다','짓누르다','짓마스다','짓무르다','짓무찌르다','짓문지르다','짓부릅뜨다',
'짓조르다','짓주무르다','짓지르다','짓찌르다','징그다','짙푸르다','짜르다','찌르다','차오르다','처박지르다','처지르다','천트다','철모르다','촉빠르다','추스르다','추슬르다','치뜨다','치르다',
'치오르다','치지르다','치켜뜨다','침담그다','칩떠오르다','칩뜨다','크나크다','크디크다','타오르다','타이르다','탈구르다','트다','판다르다','패쓰다','퍼지르다','푸르다','푸르디푸르다',
'푸르르다','풀어쓰다','피어오르다','한등누르다','해바르다','헛기르다','헤가르다','헤뜨다','헤무르다','헤프다','홉뜨다','휘두르다','휘주무르다','휘지르다','흐르다','흡뜨다','희누르다',
'희푸르다','힘쓰다'
)
var ㅅ어간 = Array(
)
}
{ //1,2글자 자주쓰는 어간배열들
Find.isHead = function(str) {
if(str.length==1) return Find.isOneHead(str)
else if(str.length==2) return Find.isTwoHead(str)
else return false
}
Find.isOneHead = function(c) { //한글자 어간인지 검사하는 함수
var head = Array( //어간 배열 (네이버 사전 ?다 검색 33번째까지 14*20=280개)
'하','가','들','되','있','받','치','오','잡','크','서','좋','놀','먹','닦','잃','찍','높','주','알',
'살','깎','앉','쉬','울','불','작','같','사','뛰','안','자','멀','듣','열','내','씻','맵','맑','늦',
'덥','걷','싸','놓','길','달','넣','웃','걸','날','쉽','묻','나','읽','입','춥','짜','벗','적','돕',
'밝','찾','싫','돌','팔','많','두','타','낮','끄','잊','쓰','말','싶','떼','죽','짓','넓','빼','따',
'갖','닫','지','피','뻗','곱','굽','맡','끓','얻','늘','밀','썩','늙','않','익','적','얼','켜','깊',
'심','식','쥐','물','추','붙','삶','차','믿','보','좁','신','쏘','벌','얕','옳','맞','붉','볶','검',
'젊','희','뜨','낳','빌','참','풀','밉','숨','뽑','끊','막','앓','담','메','눕','낡','넘','굵','묶',
'젓','쏟','짙','줄','남','떨','끼','밟','매','낫','끌','틀','세','닿','펴','덮','졸','쌓','젖','싣',
'갈','몰','줍','얇','뵈','집','붓','털','깨','얹','씹','비','업','썰','파','까','굳','맺','닯','기',
'섞','꾸','찌','뵙','빨','짚','감','베','대','박','굶','녹','묵','꺾','곧','깔','쓸','뚫','새','긋',
'뜯','접','솟','뻇','꽂','튀','띄','잇','배','겪','삼','쫓','뱉','잦','외','개','갚','덜','재','찢',
'멎','푸','없','쌔','긁','눅','삭','채','벋','닳','역','약','빚','얽','쨰','시','찧','짖','꼬','하',
'이','데','곯','떫','질','옭','줏','쇠','밭','패','밞','설','씌','곪','옅','돋','좇','누','잘','엮',
'쑤','꿰','슬','죄','뿜','트','헤','옮','엎','홅','짛','괴','째','절','잣','낚','쪼','숙','일','좃'
)
for(var i=0;i<head.length;i++) {
if(c==head[i]) return true; //어간이 있다면 true반환
}
return false; //어간이 없다면 false반환
}
Find.isTwoHead = function(str) {//두글자 어간인지 검사하는 함수
var head = Array( //어간배열 (네이버 사전 ??다 검색 44번째까지 39*15=585개)
'나가','나오','오르','가지','모르','어렵','만나','바꾸','가깝','부르','버리','바쁘','배우','아프','나쁘',
'잠자','빠르','놀라','뜨겁','비싸','예쁘','그렇','내리','춤추','안되','다르','가볍','만들','아니','보내',
'무겁','이렇','다니','맛있','잘하','말하','피우','못하','생기','지내','계시','떠나','빠지','그리','흐르',
'던지','죽이','먹이','마르','푸르','가늘','기르','찌르','싸우','지나','어둡','지우','똑같','끝나','힘들',
'뒤집','막히','더럽','싱겁','벌이','무섭','끝내','마시','떠들','지키','괜찮','내밀','놓치','앞서','오가',
'빌리','미치','이기','반갑','벌리','어리','당기','슬프','고맙','고프','즐겁','어떻','가꾸','자라','잡히',
'일하','걸리','붙이','세우','달리','통하','부르','맞추','시키','풀리','꺼내','숙이','달리','돌리','높이',
'낯설','내놓','병들','빠지','차리','외우','귀엽','모이','외롭','느리','따르','가리','나누','바뀌','이르',
'자르','빨갛','모으','가리','고치','뿌리','누르','부치','흘리','꾸미','급하','보이','늘리','밝히','진하',
'읽히','쌓이','옮기','열리','벗기','깨지','살리','밤새','놓이','꺼지','파랗','흔들','만지','까맣','견디',
'나서','넘치','취하','다하','상하','줄이','남기','먹히','약하','모시','불리','하얗','터리','비키','어리',
'건지','바르','틀리','태우','느끼','이루','잘되','넓히','더하','전하','대하','쓰이','팔리','향하','없애',
'다치','바르','둥글','멈추','두껍','울리','챙기','채우','놀랍','바라','때리','건너','위하','잠들','강하',
'정하','답하','맡기','닫히','연하','취하','맞서','알리','그립','미치','그치','차갑','마치','데리','담그',
'노랗','지치','즐기','고르','여쭈','어쩌','거치','편하','울리','웃기','떨리','안되','꿈꾸','속하','권하',
'반하','끓이','섞이','구하','담기','들리','시들','키우','저렇','기쁘','들르','괴롭','부럽','지르','우습',
'고르','따르','커지','의하','합치','착하','멋있','알맞','밤늦','열리','수많','변하','돌보','원하','심하',
'관하','잘살','친하','감추','드물','올리','힘쓰','좁히','쫒기','잘나','두르','아끼','그러','아쉽','거칠',
'점잖','사귀','넘기','끊기','못되','들이','박히','값싸','앉히','다듬','다투','흐리','잠기','기울','퍼지',
'버티','비비','다루','비치','말리','치우','걸치','날리','뻔하','묶이','익히','붙잡','엿보','깔리','낮추',
'녹이','당하','트이','찍히','묻히','환하','씌우','바치','재우','빼앗','가르','지니','순하','튀기','접하',
'안기','덮이','잘리','다지','스치','실리','서툴','비추','나뉘','잠그','피하','합하','면하','붙들','내주',
'가하','굳히','메우','뽑히','귀하','빛나','비우','청하','펴내','독하','까먹','끼우','미루','꾸리','건네',
'삼키','갖추','더불','살피','치르','띄우','아깝','졸리','뒤지','거들','이끌','달래','헤메','새기','망하',
'비하','입히','토하','맛보','놔두','뜻하','식히','폭넓','감싸','끌리','새롭','손잡','매달','머물','외치',
'밀리','놀리','기대','깨닫','닥치','저러','망치','이러','두렵','어기','잡수','붐비','불리','삼가','비기',
'같히','굽히','혼다','적히','금하','칠하','인하','멋지','꼽히','눈뜨','해내','이롭','뛰놀','씻기','만하',
'눈감','논하','빼놓','숨기','야하','비웃','데우','재밌','귀찮','나르','새우','지겹','반기','조르','묻히',
'행하','해롭','무덥','뒤늦','숨지','앞두','뻔하','체하','얄밉','욕하','애쓰','씻기','겁나','끝없','속이',
'택하','척하','듯하','흔하','얼리','내쉬','힘겹','깨우','참되','되찾','손쉽','한하','힘차','흐리','쪼이',
'돋우','되잡','매이','업히','몽글','꼬집','사납','지지','살갑','맺히','뻗치','엎치','베돌','모질','여위',
'벼리','무르','어르','내뛰','발리','지리','야위','거두','헝클','불내','구리','번지','옭히','치감','모나',
'귀먹','달붙','성나','멱따','되짚','잦히','반하','불타','쏟치','손꼽','쓰이','얼뜨','물먹','같잖','떨구',
'도르','주리','비꾀','고이','보채','가렵','누렇','끼울','보풀','메우','목매','살찌','불붙','빚지','꺾이',
'경하','죄이','들붙','낯익','못살','성내','못나','경치','깨물','눈멀','애꿏','담쌓','힘세','내닫','쩌들',
'사리','엉클','우리','갈기','퍼렇','발기','엉키','펼치','뻘겋','날래','굴리','휩쌔','튕기','가물','드리',
'둔하','역겹','설피','물리','바재','제기','벼르','후리','부풀','발갛','야리','제끼','벌겋','등치','들오',
'깎이','퍼붓','되묻','뜨이','휘돌','껴들','처먹','빤하','실없','품기','지우','철들','불나','험하','김매',
'닦이','밑지','공들','감기','들쓰','헤지','곰삭','뚫리','엎이','훑이','임하','넘놀','배곯','처지','짜이',
'골나','뺴내','늘이','폐하','엮이'
)
for(var i=0;i<head.length;i++) {
if(str==head[i]) return true; //어간이 있다면 true반환
}
return false; //어간이 없다면 false반환
}
}
/* Find 객체에 포함된 함수 정의*/
Find.형태소분리 = function(str) { //형태소로 분리해주는 함수
var SF = ''
while(str&&!str[str.length-1].match(/[가-힣]/)) { //특수기호를 저장
SF = str[str.length-1].concat(SF) //특별기호에 추가한다
str = str.substr(0,str.length-1) //특별기호 제거
}
var head = str // 최종 어간
var lastTail = '' // 최종 종결어미
var middleTail = new Array(); // 최종 선어말어미
for(var k=5;k>0;k--) { //종결어미를 긴놈부터 하나씩 검사
if(k>str.length) continue //만약 어절보다 종결어미가 길다면 넘기기
var tmpHead = str.substr(0,str.length-k) //어간인지 확인할 어절
var tmpLastTail = str.substr(str.length-k) //어미인지 확인할 어절
var tailC = P.tSound(tmpLastTail[0]) //어미의 첫글자의 받침 (부분어미에 사용할 문자)
var C_RemovedTail = tmpLastTail.replace(tmpLastTail[0],P.removeTSound(tmpLastTail[0])) //어미에서 받침을 삭제한 어미
// 규칙활용을 적용한다
var tmp = Find.규칙활용어미적용(tmpHead,tmpLastTail).split('+')
tmpHead = tmp[0]
tmpLastTail = tmp[1]
if(Find.is부분종결어미(tmpLastTail)) { // 만약 부분종결어미라면
head = tmpHead + C_RemovedTail[0] // 어간
lastTail = tailC + C_RemovedTail.substr(1) // Tail_C에 받침을 제거한 어미를 붙인것
break; //탈출
}
if(Find.is종결어미(tmpLastTail)) { //만약 종결어미라면
head = tmpHead
lastTail = tmpLastTail
break; //탈출
}
//불규칙활용을 적용한다
var tmp = Find.불규칙활용어미적용(tmpHead,tmpLastTail).split('+')
tmpHead = tmp[0]
tmpLastTail = tmp[1]
if(Find.is부분종결어미(tmpLastTail)) { // 만약 부분종결어미라면
head = tmpHead+C_RemovedTail[0] // 어간
lastTail = tailC + C_RemovedTail.substr(1) // Tail_C에 받침을 제거한 어미를 붙인것
break; //탈출
}
if(Find.is종결어미(tmpLastTail)) { //만약 종결어미라면
head = tmpHead
lastTail = tmpLastTail
break; //탈출
}
}
if(lastTail!='')
lastTail = '-' + lastTail
for(var k=3;k>0;k--) { //선어말어미를 긴놈부터 하나씩 검사
if(!lastTail || k>head.length) continue; //종결어미가 없거나 k보다 크다면 넘기기
var tmpHead = head.substr(0,head.length-k) //어간인지 확인할 어절
var tmpMidTail = head.substr(head.length-k) //어미인지 확인할 어절
var tailC = P.tSound(tmpMidTail[0]) //어미의 첫글자의 받침 (부분어미에 사용할 문자)
var C_RemovedTail = tmpMidTail.replace(tmpMidTail[0],P.removeTSound(tmpMidTail[0])) //어미에서 받침을 삭제한 어미
// 규칙활용을 적용한다
var tmp = Find.규칙활용어미적용(tmpHead,tmpMidTail).split('+')
tmpHead = tmp[0]
tmpMidTail = tmp[1]
if(Find.is선어말어미(tmpMidTail)) { // 만약 선어말어미일경우
middleTail.push('-'+tmpMidTail+'-') // 선어말어미 배열안에 어미를 넣는다
head = head.substr(0,head.length-k) //선어말어미 제거
k = 3 // 루프를 다시 돈다
}
if(Find.is부분선어말어미(tmpMidTail)) {//만약 선어말어미일경우
if(tailC=='') continue
middleTail.push('-'+tailC+'-') // 선어말어미 배열안에 어미를 넣는다
head = head.substr(0,head.length-k).concat(C_RemovedTail) // 선어말어미 제거
k = 3 // 루프를 다시 돈다
}
//불규칙활용을 적용한다
var tmp = Find.불규칙활용어미적용(tmpHead,tmpMidTail).split('+')
tmpHead = tmp[0]
tmpMidTail = tmp[1]
if(Find.is선어말어미(tmpMidTail)) { // 만약 선어말어미일경우
if(tmpMidTail==middleTail[middleTail.length-1]) continue
middleTail.push('-'+tmpMidTail+'-') // 선어말어미 배열안에 어미를 넣는다
head = head.substr(0,head.length-k) //선어말어미 제거
k = 3 // 루프를 다시 돈다
}
if(Find.is부분선어말어미(tmpMidTail)) {//만약 선어말어미일경우
if(tailC=='') continue
if(tmpMidTail==middleTail[middleTail.length-1]) continue
middleTail.push('-'+tailC+'-') // 선어말어미 배열안에 어미를 넣는다
head = head.substr(0,head.length-k).concat(C_RemovedTail) // 선어말어미 제거
k = 3 // 루프를 다시 돈다
}
}
//console.log(head+'+'+middleTail+'+'+lastTail+'+'+SF)
var resultArray = new Array()
if(head!='')
resultArray.push(head)
for(var i=middleTail.length-1;i>=0;i--) { //반대로 저장
resultArray.push(middleTail[i])
}
if(lastTail!='')
resultArray.push(lastTail)
var result = ''
if(SF!='')
resultArray.push(SF)
for(var i=0;i<resultArray.length;i++) {
result = result.concat(resultArray[i]+"+")
}
return result.substr(0,result.length-1) //일치하지 않는다면 그대로 반환
}
Find.isㅡhead = function(str) { // ㅡ어간인지 확인하는 함수
for(var i=0;i<ㅡ어간.length;i++) {
if(str==ㅡ어간[i]) return true
}
return false
}
Find.isㄹhead = function(str) { // ㄹ어간인지 확인하는 함수
for(var i=0;i<ㄹ어간.length;i++) {
if(str==ㄹ어간[i]) return true
}
return false
}
Find.is종결어미 = function(str) { // 종결어미인지 확인하는 함수
for(var i=0;i<종결어미.length;i++) {
if(str==종결어미[i]) return true
}
return false
}
Find.is부분종결어미 = function(tail) { //부분종결어미인지 확인하는 함수
var C = P.tSound(tail[0])
var C_RemovedTail = tail.substr(0,tail.length-1) + P.removeTSound(tail[tail.length-1])
if(tail.length==1&&(P.isSameSound(C,'ㄴ')||P.isSameSound(C,'ㄹ')||P.isSameSound(C,'ㅁ'))&&Find.isHead(C_RemovedTail)) {
return true
}
for(var i=0;i<부분종결어미.length;i++) {
if(tail.length!=1&&P.isSameSound(C,부분종결어미[i][0]) && tail.substr(1)==부분종결어미[i].substr(1)) { //자음과 부분종결어미가 같다면
return true
}
}
return false
}
Find.is선어말어미 = function(str) { //선어말어미인지 확인하는 함수
for(var i=0;i<선어말어미.length;i++) {
if(str==선어말어미[i]) return true
}
return false
}
Find.is부분선어말어미 = function(tail) {
//if(tail[0]=='는') return false
var C = P.tSound(tail[tail.length-1])
var C_RemovedTail = tail.substr(0,tail.length-1) + P.removeTSound(tail[tail.length-1])
if(P.isSameSound(C,'ㄴ')&&Find.isHead(C_RemovedTail))
return true
else
return false
}
//문제점, 상관없는거까지 변형을 해버림 -> 어간 확인 완료
Find.규칙활용어미적용 = function(head,tail) { //규칙활용어미인지 확인하여 "어간+어미"으로 반환
var Tail_isound = P.iSound(tail[0])
var Tail_msound = P.mSound(tail[0])
var Tail_tsound = P.tSound(tail[0])
var Head_tsound = P.tSound(head[head.length-1])
if(head=='' && tail.length==1) { //한글자일때 따로 처리
if(P.tSound(tail)) {
}
}
//'ㄹ' 탈락 : 어간의 끝소리 'ㄹ'이 'ㄴ','ㅂ','ㅅ','오'앞에서 규칙적으로 탈락되는 용언
if((P.isSameSound(Tail_isound,'ㄴ') //어미의 초성이 'ㄴ'일때
||P.isSameSound(Tail_isound,'ㅂ') //어미의 초성이 'ㅂ'일때
||P.isSameSound(Tail_isound,'ㅅ') //어미의 초성이 'ㅅ'일떄
||tail[0]=="오") //마지막 글자가 '오'일때
&&P.tSound(tail[0]) == '' //
&&head.length>0) // 어간이 존재할때
{
//앞에 탈락된 ㄹ을 붙여준다
var tmpHead = head.substr(0,head.length-1) + P.addTSound(head[head.length-1],'ㄹ')
var tmpTail = tail
if(Find.isㄹhead(tmpHead+'다')) { //&& Find.is종결어미(tmpTail)){ //만약 어미고 어간이 존재한다면 (어간은 나중에 확인)
return tmpHead + '+' + tmpTail
}
}
if(P.isSameSound(Head_tsound,'ㄴ') //어미 'ㄴ'일때
||P.isSameSound(Head_tsound,'ㅂ')) //어미'ㅂ'일때
{
//앞에 탈락된 ㄹ을 붙여준다
var tmpHead = head.substr(0,head.length-1) + P.addTSound(head[head.length-1],'ㄹ')
var tmpTail = Head_tsound
if(Find.isㄹhead(tmpHead+'다')) { //&& Find.is종결어미(tmpTail)){ //만약 어미고 어간이 존재한다면 (어간은 나중에 확인)
return tmpHead + '+' + tmpTail
}
}
//'ㅡ' 탈락 : 어말어미 '-아/-어'로 시작되는 어미 및 선어말 어미 '-았/었-'앞에서 규칙적으로 탈락되는 용언
if((P.isSameSound(Tail_msound,'ㅏ') || P.isSameSound(Tail_msound,'ㅓ')) // 어미의 중성이 'ㅏ','ㅓ'
&& (Tail_tsound == '' || P.isSameSound(Tail_tsound,'ㅆ')))// 어미의 종성이 존재하지 않거나 'ㅆ'일때
{
//탈락된 'ㅡ'를 붙여준다
var tmpHead = head.substr(0,head.length-1) + P.removeTSound(head[head.length-1]) + P.assembleSound(P.iSound(tail[0]),'ㅡ','')
var tmpTail = P.assembleSound('ㅇ',P.mSound(tail[0]),P.tSound(tail[0])) + tail.substr(1)
if(Find.isㅡhead(tmpHead+'다')) { //&& Find.isFullEndTail(tmpTail)) { //만약 어미고 어간이 존재한다면 (어간은 나중에 확인)
return tmpHead + '+' + tmpTail
}
}
return head + '+' + tail
}
//
Find.불규칙활용어미적용 = function(head,tail) { //불규칙활용어미인지 확인하는 함수
var Tail_isound = P.iSound(tail[0])
var Tail_msound = P.mSound(tail[0])
var Tail_tsound = P.tSound(tail[0])
var Head_tsound = P.tSound(head[head.length-1])
var Head_last = head[head.length-1]
var tmpHead = head
var tmpTail = tail
//'ㅅ' 탈락 : 어간의 끝소리인 'ㅅ'이 모음 어미 앞에서 탈락
//불규칙 : (잇다 짓다 긋다 낫다) 규칙 : (벗다 빗다 솟다)
if(P.isSameSound(Tail_isound,'ㅇ')) { //마지막 자음이 'ㅇ'일때 (모음은 항상 존재하므로)
if(head&&Head_last.match(/[이지그나]/)) //불규칙활용 어간일때
{
var tmpHead = head.substr(0,head.length-1) + P.assembleSound(P.iSound(Head_last),P.mSound(Head_last),'ㅅ')
var tmpTail = tail
}
}
//'ㄷ' 변형 : 어간의 끝소리 'ㄷ'이 모음 어미 앞에서 'ㄹ'로 변하는것
//불규칙 : (듣다 걷다 일컫다) 규칙 : (닫다 믿다 얻다)
if(P.isSameSound(Tail_isound,'ㅇ') //모음일때
&&P.isSameSound(Head_tsound,'ㄹ')) {
if(head&&Head_last.match(/[들걸컬]/))
{
var tmpHead = head.substr(0,head.length-1) + P.assembleSound(P.iSound(Head_last),P.mSound(Head_last),'ㄷ')
var tmpTail = tail
}
}
//'ㅂ' 변형 : 어간의 끝소리 'ㅂ'이 모음 어미 앞에서 '오/우'로 바뀜
//불규칙 : (굽다 깁다 눕다 줍다 돕다 곱다) 규칙 : (입다 집다 좁다)
if(P.isSameSound(Tail_isound,'ㅇ') //자음이 'ㅇ'음일때
&&(P.isSameSound(Tail_msound,'ㅘ') || P.isSameSound(Tail_msound,'ㅙ') || P.isSameSound(Tail_msound,'ㅝ') //ㅘㅙㅝㅝㅞㅟ
||P.isSameSound(Tail_msound,'ㅝ') || P.isSameSound(Tail_msound,'ㅞ') || P.isSameSound(Tail_msound,'ㅟ'))) {
if(head&&Head_last.match(/[구기누주도고]/)) //불규칙어간일때
{
var tmpHead = head.substr(0,head.length-1) + P.assembleSound(P.iSound(Head_last),P.mSound(Head_last),'ㅂ')
var tmpTail = tail
}
}
//'르' 추가 : 어간의 끝소리 '르'가 모음 어미 앞에서 '르'의 '으'가 탈락되면서 'ㄹ'이 덧 생김
//불규칙 : (오르다 나르다 흐르다 다르다 가르다) 규칙 : (따르다 치르다 들르다)
if(P.isSameSound(P.iSound(Head_last),'ㄹ')
||P.isSameSound(Tail_isound,'ㄹ'))
{
if(head&&Head_last.match(/[올날흘달갈]/)) //불규칙어간일때
{
var tmpHead = head.substr(0,head.length-1) + P.removeTSound(Head_last) + '르'
var tmpTail = P.assembleSound('ㅇ',Tail_msound,Tail_tsound) + tail.substr(1)
}
}
//'우' 탈락 : '우'가 모음 어미 앞에서 탈락
//불규칙 : (푸다) 규칙 : (주다 두다 추다 누다)
if(P.isSameSound(Tail_isound,'ㅍ'))
{
var tmpHead = '푸'
var tmpTail = P.assembleSound('ㅇ',Tail_msound,Tail_tsound)
}
return tmpHead + '+' + tmpTail
}
/* P 객체에 포함된 함수 정의*/
P.iSound = function(a) { //초성을 반환하는 함수
if(a==undefined) return
if(!a.match(/[가-힣]/)) return //한글이 아니라면 리턴
var r = ((a.charCodeAt(0) - parseInt('0xac00',16)) /28) / 21;
var t = String.fromCharCode(r + parseInt('0x1100',16));
return t;
};
P.mSound = function(a) { //중성을 반환하는 함수
if(a==undefined) return
if(!a.match(/[가-힣]/)) return //한글이 아니라면 리턴
var r = ((a.charCodeAt(0)- parseInt('0xac00',16)) / 28) % 21;
var t = String.fromCharCode(r + parseInt('0x1161',16));
return t;
};
P.tSound = function(a) { //종성을 반환하는 함수
if(a==undefined) return ''
if(!a.match(/[가-힣]/)) return '오류'//한글이 아니라면 리턴
var r = (a.charCodeAt(0) - parseInt('0xac00',16)) % 28;
var t = String.fromCharCode(r + parseInt('0x11A8') -1);
if(r==0) return ''; //종성이 없다면 ''반환
else return t;
};
P.removeTSound = function(a) { //종성을 없애는 함수
if(a==undefined) return ''
if(!a.match(/[가-힣]/)) return '오류' //한글이 아니라면 리턴
var r = (a.charCodeAt(0) - parseInt('0xac00',16)) - ((a.charCodeAt(0) - parseInt('0xac00',16)) % 28);
var t = String.fromCharCode(r + parseInt('0xac00',16))
return t;
}
P.isSameSound = function(a,b) { //같은 모음/자음인지 확인하는 함수
if(a==undefined||b==undefined) return false
var Mnum_a = -1 //처음에 다 다르게 설정
var Mnum_b = -2
var Inum_a = -3
var Inum_b = -4
switch(a) { //자음
case "ᄀ":
case "ᆨ":
case "ㄱ": Inum_a = 0; break
case 'ᄁ':
case "ᆩ":
case "ㄲ": Inum_a = 1; break
case "ᄂ":
case "ᆫ":
case "ㄴ": Inum_a = 2; break
case "ᄃ":
case "ᆮ":
case "ㄷ": Inum_a = 3; break
case "ᄄ":
case "ㄸ": Inum_a = 4; break
case "ᄅ":
case "ᆯ":
case "ㄹ": Inum_a = 5; break
case "ᄆ":
case "ᆷ":
case "ㅁ": Inum_a = 6; break
case "ᄇ":
case "ᆸ":
case "ㅂ": Inum_a = 7; break
case "ᄈ":
case "ㅃ": Inum_a = 8; break
case "ᄉ":
case "ᆺ":
case "ㅅ": Inum_a = 9; break
case "ᄊ":
case "ᆻ":
case "ㅆ": Inum_a = 10; break
case "ᄋ":
case "ᆼ":
case "ㅇ": Inum_a = 11; break
case "ᄌ":
case "ᆽ":
case "ㅈ": Inum_a = 12; break
case "ᄍ":
case "ㅉ": Inum_a = 13; break
case "ᄎ":
case "ᆾ":
case "ㅊ": Inum_a = 14; break
case "ᄏ":
case "ᆿ":
case "ㅋ": Inum_a = 15; break
case "ᄐ":
case "ᇀ":
case "ㅌ": Inum_a = 16; break
case "ᄑ":
case "ᇁ":
case "ㅍ": Inum_a = 17; break
case "ᄒ":
case "ᇂ":
case "ㅎ": Inum_a = 18; break
}
switch(b) { //자음
case "ᄀ":
case "ᆨ":
case "ㄱ": Inum_b = 0; break
case 'ᄁ':
case "ᆩ":
case "ㄲ": Inum_b = 1; break
case "ᄂ":
case "ᆫ":
case "ㄴ": Inum_b = 2; break
case "ᄃ":
case "ᆮ":
case "ㄷ": Inum_b = 3; break
case "ᄄ":
case "ㄸ": Inum_b = 4; break
case "ᄅ":
case "ᆯ":
case "ㄹ": Inum_b = 5; break
case "ᄆ":
case "ᆷ":
case "ㅁ": Inum_b = 6; break
case "ᄇ":
case "ᆸ":
case "ㅂ": Inum_b = 7; break
case "ᄈ":
case "ㅃ": Inum_b = 8; break
case "ᄉ":
case "ᆺ":
case "ㅅ": Inum_b = 9; break
case "ᄊ":
case "ᆻ":
case "ㅆ": Inum_b = 10; break
case "ᄋ":
case "ᆼ":
case "ㅇ": Inum_b = 11; break
case "ᄌ":
case "ᆽ":
case "ㅈ": Inum_b = 12; break
case "ᄍ":
case "ㅉ": Inum_b = 13; break
case "ᄎ":
case "ᆾ":
case "ㅊ": Inum_b = 14; break
case "ᄏ":
case "ᆿ":
case "ㅋ": Inum_b = 15; break
case "ᄐ":
case "ᇀ":
case "ㅌ": Inum_b = 16; break
case "ᄑ":
case "ᇁ":
case "ㅍ": Inum_b = 17; break
case "ᄒ":
case "ᇂ":
case "ㅎ": Inum_b = 18; break
}
switch(a) { //모음변환
case "ᅡ":
case "ㅏ": Mnum_a = 0; break
case "ᅢ":
case "ㅐ": Mnum_a = 1; break
case "ᅣ":
case "ㅑ": Mnum_a = 2; break
case "ᅤ":
case "ㅒ": Mnum_a = 3; break
case "ᅥ":
case "ㅓ": Mnum_a = 4; break
case "ᅦ":
case "ㅔ": Mnum_a = 5; break
case "ᅧ":
case "ㅕ": Mnum_a = 6; break
case "ᅨ":
case "ㅖ": Mnum_a = 7; break
case "ᅩ":
case "ㅗ": Mnum_a = 8; break
case "ᅪ":
case "ㅘ": Mnum_a = 9; break
case "ᅫ":
case "ㅙ": Mnum_a = 10; break
case "ᅬ":
case "ㅚ": Mnum_a = 11; break
case "ᅭ":
case "ㅛ": Mnum_a = 12; break
case "ᅮ":
case "ㅜ": Mnum_a = 13; break
case "ᅯ":
case "ㅝ": Mnum_a = 14; break
case "ᅰ":
case "ㅞ": Mnum_a = 15; break
case "ᅱ":
case "ㅟ": Mnum_a = 16; break
case "ᅲ":
case "ㅠ": Mnum_a = 17; break
case "ᅳ":
case "ㅡ": Mnum_a = 18; break
case "ᅴ":
case "ㅢ": Mnum_a = 19; break
case "ᅵ":
case "ㅣ": Mnum_a = 20; break
}
switch(a) { //모음변환
case "ᅡ":
case "ㅏ": Mnum_b = 0; break
case "ᅢ":
case "ㅐ": Mnum_b = 1; break
case "ᅣ":
case "ㅑ": Mnum_b = 2; break
case "ᅤ":
case "ㅒ": Mnum_b = 3; break
case "ᅥ":
case "ㅓ": Mnum_b = 4; break
case "ᅦ":
case "ㅔ": Mnum_b = 5; break
case "ᅧ":
case "ㅕ": Mnum_b = 6; break
case "ᅨ":
case "ㅖ": Mnum_b = 7; break
case "ᅩ":
case "ㅗ": Mnum_b = 8; break
case "ᅪ":
case "ㅘ": Mnum_b = 9; break
case "ᅫ":
case "ㅙ": Mnum_b = 10; break
case "ᅬ":
case "ㅚ": Mnum_b = 11; break
case "ᅭ":
case "ㅛ": Mnum_b = 12; break
case "ᅮ":
case "ㅜ": Mnum_b = 13; break
case "ᅯ":
case "ㅝ": Mnum_b = 14; break
case "ᅰ":
case "ㅞ": Mnum_b = 15; break
case "ᅱ":
case "ㅟ": Mnum_b = 16; break
case "ᅲ":
case "ㅠ": Mnum_b = 17; break
case "ᅳ":
case "ㅡ": Mnum_b = 18; break
case "ᅴ":
case "ㅢ": Mnum_b = 19; break
case "ᅵ":
case "ㅣ": Mnum_b = 20; break
}
if(Inum_a==Inum_b||Mnum_a==Mnum_b) return true //하나라도 서로 같으면 true반환
else return false
}
P.is자음 = function(a) { //자음인지 확인하는 함수
var Tnum = -1;
switch(a) { //종성변환
case "" : Tnum = 0; break
case "ᄀ":
case "ᆨ":
case "ㄱ": Tnum = 1; break
case "ᄁ":
case "ᆩ":
case "ㄲ": Tnum = 2; break
case "ᆪ":
case "ㄳ": Tnum = 3; break
case "ᄂ":
case "ᆫ":
case "ㄴ": Tnum = 4; break
case "ᆬ":
case "ㄵ": Tnum = 5; break
case "ᆭ":
case "ㄶ": Tnum = 6; break
case "ᄃ":
case "ᆮ":
case "ㄷ": Tnum = 7; break
case "ᄅ":
case "ᆯ":
case "ㄹ": Tnum = 8; break
case "ᆰ":
case "ㄺ": Tnum = 9; break
case "ᆱ":
case "ㄻ": Tnum = 10; break
case "ᆲ":
case "ㄼ": Tnum = 11; break
case "ᆳ":
case "ㄽ": Tnum = 12; break
case "ᆴ":
case "ㄾ": Tnum = 13; break
case "ᆵ":
case "ㄿ": Tnum = 14; break
case "ᆶ":
case "ㅀ": Tnum = 15; break
case "ᄆ":
case "ᆷ":
case "ㅁ": Tnum = 16; break
case "ᄇ":
case "ᆸ":
case "ㅂ": Tnum = 17; break
case "ᆹ":
case "ㅄ": Tnum = 18; break
case "ᄉ":
case "ᆺ":
case "ㅅ": Tnum = 19; break
case "ᄊ":
case "ᆻ":
case "ㅆ": Tnum = 20; break
case "ᄋ":
case "ᆼ":
case "ㅇ": Tnum = 21; break
case "ᄌ":
case "ᆽ":
case "ㅈ": Tnum = 22; break
case "ᄎ":
case "ᆾ":
case "ㅊ": Tnum = 23; break
case "ᄏ":
case "ᆿ":
case "ㅋ": Tnum = 24; break
case "ᄐ":
case "ᇀ":
case "ㅌ": Tnum = 25; break
case "ᄑ":
case "ᇁ":
case "ㅍ": Tnum = 26; break
case "ᄒ":
case "ᇂ":
case "ㅎ": Tnum = 27; break
}
if(Tnum>=0) return true
else return false
}
P.is모음 = function(a) { //모음인지 확인하는 함수
var Mnum_a = -1;
switch(a) { //모음변환
case "ᅡ":
case "ㅏ": Mnum_a = 0; break
case "ᅢ":
case "ㅐ": Mnum_a = 1; break
case "ᅣ":
case "ㅑ": Mnum_a = 2; break
case "ᅤ":
case "ㅒ": Mnum_a = 3; break
case "ᅥ":
case "ㅓ": Mnum_a = 4; break
case "ᅦ":
case "ㅔ": Mnum_a = 5; break
case "ᅧ":
case "ㅕ": Mnum_a = 6; break
case "ᅨ":
case "ㅖ": Mnum_a = 7; break
case "ᅩ":
case "ㅗ": Mnum_a = 8; break
case "ᅪ":
case "ㅘ": Mnum_a = 9; break
case "ᅫ":
case "ㅙ": Mnum_a = 10; break
case "ᅬ":
case "ㅚ": Mnum_a = 11; break
case "ᅭ":
case "ㅛ": Mnum_a = 12; break
case "ᅮ":
case "ㅜ": Mnum_a = 13; break
case "ᅯ":
case "ㅝ": Mnum_a = 14; break
case "ᅰ":
case "ㅞ": Mnum_a = 15; break
case "ᅱ":
case "ㅟ": Mnum_a = 16; break
case "ᅲ":
case "ㅠ": Mnum_a = 17; break
case "ᅳ":
case "ㅡ": Mnum_a = 18; break
case "ᅴ":
case "ㅢ": Mnum_a = 19; break
case "ᅵ":
case "ㅣ": Mnum_a = 20; break
}
if(Mnum_a>=0) return true
else return false
}
P.addTSound = function(a,tSound) { //종성을 더해주는 함수
a = P.removeTSound(a)
var num = 0;
switch(tSound) {
case "ㄱ": num = 1; break
case "ㄲ": num = 2; break
case "ㄳ": num = 3; break
case "ㄴ": num = 4; break
case "ㄵ": num = 5; break
case "ㄶ": num = 6; break
case "ㄷ": num = 7; break
case "ㄹ": num = 8; break
case "ㄺ": num = 9; break
case "ㄻ": num = 10; break
case "ㄼ": num = 11; break
case "ㄽ": num = 12; break
case "ㄾ": num = 13; break
case "ㄿ": num = 14; break
case "ㅀ": num = 15; break
case "ㅁ": num = 16; break
case "ㅂ": num = 17; break
case "ㅄ": num = 18; break
case "ㅅ": num = 19; break
case "ㅆ": num = 20; break
case "ㅇ": num = 21; break
case "ㅈ": num = 22; break
case "ㅊ": num = 23; break
case "ㅋ": num = 24; break
case "ㅌ": num = 25; break
case "ㅍ": num = 26; break
case "ㅎ": num = 27; break
}
r = a.charCodeAt(0) + num //종성을 더함
var t = String.fromCharCode(r)
return t
}
P.assembleSound = function(iSound,mSound,tSound) { //초성,중성,종성을 합하는 함수
var Inum = -1, Mnum = -1, Tnum = -1;
switch(iSound) { //초성변환 //초성,종성,일반 순
case "ᄀ":
case "ᆨ":
case "ㄱ": Inum = 0; break
case 'ᄁ':
case "ᆩ":
case "ㄲ": Inum = 1; break
case "ᄂ":
case "ᆫ":
case "ㄴ": Inum = 2; break
case "ᄃ":
case "ᆮ":
case "ㄷ": Inum = 3; break
case "ᄄ":
case "ㄸ": Inum = 4; break
case "ᄅ":
case "ᆯ":
case "ㄹ": Inum = 5; break
case "ᄆ":
case "ᆷ":
case "ㅁ": Inum = 6; break
case "ᄇ":
case "ᆸ":
case "ㅂ": Inum = 7; break
case "ᄈ":
case "ㅃ": Inum = 8; break
case "ᄉ":
case "ᆺ":
case "ㅅ": Inum = 9; break
case "ᄊ":
case "ᆻ":
case "ㅆ": Inum = 10; break