Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

546 lines
19 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 1997, Microsoft Corporation. All Rights Reserved.
  4. //
  5. // COMPOSE.CPP
  6. // These funtions is to compose the word with stem and ending.
  7. // If you want to understand more details, get the flow chart.
  8. // made by dhyu 1996. 2
  9. //
  10. /////////////////////////////////////////////////////////////////////////////
  11. #include <windows.h>
  12. #include "basedef.hpp"
  13. #include "basedict.hpp"
  14. #include "basegbl.hpp"
  15. #include "ReadHeosaDict.h"
  16. /*
  17. extern char far _IA_BP, // a3+ : PIEUP irregular light adjective
  18. far _RA_B, // a3r : PIEUP regular light adjective
  19. far _IA_HP, // a5+ : HIEUH irregular light adjective
  20. far _IA_HM, // a5- : HIEUH irregular dark adjective
  21. far _IA_RmP, // a6+ : REU irregular light adjective
  22. far _IA_RmM, // a6- : REU irregular dark adjective
  23. far _IA_Rj, // a7 : REO irregular adjective
  24. far _IA_OmP, // a8+ : EU irregular light adjective
  25. far _IA_OmM, // a8- : EU irregular dark adjective
  26. far _IV_DP, // v2+ : TIEUT irregular light verb
  27. far _IV_DM, // v2- : TIEUT irregular dark verb
  28. far _IV_Gj, // v0 : GEORA irregular verb
  29. far _IV_Nj, // v1 : NEORA irregular verb
  30. far _RV_D, // v2r : TIEUT regular verb
  31. far _IV_BP, // v3+ : PIEUP irregular light verb
  32. far _IV_BM, // v3- : PIEUP irregular dark verb
  33. far _IV_SP, // v4+ : SIOS irregular light verb
  34. far _IV_SM, // v4- : SIOS irregular dark verb
  35. far _IV_RmP, // v6+ : REU irregular light verb
  36. far _IV_RmM, // v6- : REU irregular dark verb
  37. far _IV_Rj, // v7 : REO irregular verb
  38. far _IV_OmP, // v8+ : EU irregular light verb
  39. far _IV_OmM; // v8- : EU irregular dark verb
  40. */
  41. // check wether right most vowel of stem is light vowel, or not
  42. // stem should be reverse order
  43. BOOL CheckRightMostStemVowel (char *stem)
  44. {
  45. char vowel;
  46. if (stem [0] < __V_k)
  47. vowel = stem [1];
  48. else
  49. vowel = stem [0];
  50. switch (vowel)
  51. {
  52. case __V_k :
  53. case __V_i :
  54. case __V_h : return TRUE;
  55. }
  56. return FALSE;
  57. }
  58. int Compose_RIEUL_Irregular (char *stem, char *ending)
  59. {
  60. int i, len;
  61. char *inheosa;
  62. if (stem [0] == __K_R)
  63. {
  64. switch (ending [0])
  65. {
  66. case __K_I :
  67. switch (ending [1])
  68. {
  69. case __V_j :
  70. if (CheckRightMostStemVowel (stem)) // vowel harmony
  71. ending [1] = __V_k;
  72. return COMPOSED;
  73. case __V_m :
  74. if (ending [2] != __K_M)
  75. memmove (stem, stem + 1, lstrlen (stem)); // remove "RIEUL"
  76. memmove (ending, ending + 2, lstrlen (ending+1)); // remove "IEUNG, EU"
  77. return COMPOSED;
  78. default : return COMPOSE_ERROR;
  79. }
  80. case __K_S :
  81. memmove (stem, stem + 1, lstrlen (stem)); // remove "RIEUL"
  82. if (ending [1] == __V_m)
  83. memmove (ending, ending + 2, lstrlen (ending+1)); // remove "SIOS, EU"
  84. return COMPOSED;
  85. case __K_N :
  86. memmove (stem, stem + 1, lstrlen (stem)); // remove "RIEUL"
  87. len = lstrlen(ending);
  88. inheosa = new char [len+1];
  89. for (i = 0; i < len; i++)
  90. inheosa [i] = ending [len-1-i];
  91. inheosa [i] = '\0';
  92. BYTE action;
  93. FindHeosaWord (inheosa, _ENDING, &action);
  94. if ((action & 0x80) && !(action & 0x40)) // if CV = 10
  95. memmove (ending, ending + 2, lstrlen (ending+1)); // remove "NIEUN, EU"
  96. return COMPOSED;
  97. case __K_G :
  98. case __K_D :
  99. case __K_J : return COMPOSED;
  100. default : return COMPOSE_ERROR;
  101. }
  102. }
  103. return NOT_COMPOSED;
  104. }
  105. int Compose_HIEUH_Irregular (char *stem, char *ending)
  106. {
  107. if (stem [0] == __K_H)
  108. {
  109. int len = lstrlen(stem);
  110. char * inheosa = new char [len+1];
  111. for (int i = 0; i < len; i++)
  112. inheosa [i] = stem [len-1-i];
  113. inheosa [i] = '\0';
  114. switch (ending [0])
  115. {
  116. case __K_I :
  117. if (FindIrrWord(inheosa, _IA_HP) & FINAL || // HIEUH irregular light adjective (A5+)
  118. FindIrrWord(inheosa, _IA_HM) & FINAL) // HIEUH irregular dark adjective (A5-)
  119. {
  120. switch (ending [1])
  121. {
  122. case __V_j : // "IEUNG, EO"
  123. memmove (stem, stem+1, lstrlen(stem)); // remove "HIEUH"
  124. memmove (ending, ending + 2, lstrlen (ending+1)); // remove "IEUNG, EO"
  125. switch (stem [0])
  126. {
  127. case __V_k : stem [0] = __V_o; return COMPOSED;
  128. case __V_j : stem [0] = __V_p; return COMPOSED;
  129. case __V_i : stem [0] = __V_O; return COMPOSED;
  130. case __V_u : stem [0] = __V_P; return COMPOSED;
  131. default : return COMPOSE_ERROR;
  132. }
  133. case __V_m : // "IEUNG, EU"
  134. memmove (stem, stem+1, lstrlen(stem)); // remove "HIEUH"
  135. memmove (ending, ending + 2, lstrlen (ending+1)); // remove "IEUNG, EU"
  136. return COMPOSED;
  137. default :
  138. return COMPOSE_ERROR;
  139. }
  140. }
  141. switch (ending [1])
  142. {
  143. case __V_j :
  144. if (CheckRightMostStemVowel (stem)) // vowel harmony
  145. ending [1] = __V_k;
  146. return COMPOSED;
  147. case __V_m : return COMPOSED;
  148. default : return COMPOSE_ERROR;
  149. }
  150. case __K_N : // "NIEUN"
  151. if (FindIrrWord(inheosa, _IA_HP) & FINAL || // HIEUH irregular light adjective (A5+)
  152. FindIrrWord(inheosa, _IA_HM) & FINAL) // HIEUH irregular dark adjective (A5-)
  153. memmove (stem, stem+1, lstrlen(stem)); // remove "HIEUH"
  154. return COMPOSED;
  155. case __K_G :
  156. case __K_S :
  157. case __K_J : return COMPOSED;
  158. default : return COMPOSE_ERROR;
  159. }
  160. }
  161. return NOT_COMPOSED;
  162. }
  163. int Compose_PIEUP_Irregular (char *stem, char *ending)
  164. {
  165. if (stem [0] == __K_B)
  166. {
  167. int len = lstrlen(stem);
  168. char * inheosa = new char [len+1];
  169. for (int i = 0; i < len; i++)
  170. inheosa [i] = stem [len-1-i];
  171. inheosa [i] = '\0';
  172. if (FindIrrWord(inheosa, _IV_BP) & FINAL || // PIEUP irregular light verb (V3+)
  173. FindIrrWord(inheosa, _IA_BP) & FINAL) // PIEUP irregular light adjective (A3+)
  174. {
  175. if (ending [0] == __K_I)
  176. {
  177. if (ending [1] == __V_j)
  178. {
  179. // "PIEUP, IEUNG, EO" --> "IEUNG, WA"
  180. memmove (stem, stem+1, lstrlen(stem));
  181. ending [1] = __V_hk;
  182. return COMPOSED;
  183. }
  184. if (ending [1] == __V_m) // "IEUNG, EU"
  185. {
  186. // "PIEUP, IEUNG, EU" --> "IEUNG, U"
  187. memmove (stem, stem+1, lstrlen(stem)); // remove "PIEUP"
  188. ending [1] = __V_n;
  189. return COMPOSED;
  190. }
  191. }
  192. return COMPOSED;
  193. }
  194. char Temp [] = {
  195. __K_G_D, __V_h, __K_B, 0, 0, 1,
  196. __K_B, __V_k, __K_R, __K_B, 0, 2,
  197. __K_B_D, __V_h, __K_B, 0, 0, 1,
  198. __K_S_D, __V_l, __K_B, 0, 0, 1,
  199. __K_I, __V_j, __K_B, 0, 0, 1,
  200. __K_I, __V_l, __K_B, 0, 0, 1,
  201. __K_J, __V_k, __K_B, 0, 0, 1,
  202. __K_J, __V_j, __K_B, 0, 0, 1,
  203. __K_J, __V_l, __K_B, 0, 0, 1
  204. };
  205. LenDict RV_B (Temp, 6, 9);
  206. int eulpos = lstrlen (inheosa) - 1;
  207. if (FindIrrWord(inheosa, _RA_B) & FINAL || // PIEUP regular adjective (a3r)
  208. RV_B.FindWord(inheosa, eulpos) != -1) // PIEUP regular verb
  209. {
  210. if (ending [0] == __K_I && ending [1] == __V_j) // "IEUNG, EO"
  211. {
  212. if (CheckRightMostStemVowel (stem)) // vowel harmony
  213. ending [1] = __V_k;
  214. }
  215. return COMPOSED;
  216. }
  217. if (ending [0] == __K_I)
  218. {
  219. if (ending [1] == __V_j)
  220. {
  221. // "PIEUP, IEUNG, EO" --> "IEUNG, WA"
  222. memmove (stem, stem+1, lstrlen(stem));
  223. ending [1] = __V_hk;
  224. return COMPOSED;
  225. }
  226. if (ending [0] == __K_I && ending [1] == __V_m) // "IEUNG, EU"
  227. {
  228. memmove (stem, stem+1, lstrlen(stem)); // remove "HIEUH"
  229. memmove (ending, ending + 2, lstrlen (ending+1)); // "IEUNG, EU" --> "IEUNG"
  230. return COMPOSED;
  231. }
  232. }
  233. return COMPOSED;
  234. }
  235. return NOT_COMPOSED;
  236. }
  237. int Compose_TIEUT_Irregular (char *stem, char *ending)
  238. {
  239. int i, len;
  240. char *inheosa;
  241. if (stem [0] == __K_D)
  242. {
  243. if (ending [0] == __K_I)
  244. {
  245. switch (ending [1])
  246. {
  247. case __V_j : // "EO"
  248. if (CheckRightMostStemVowel (stem)) // vowel harmony
  249. ending [1] = __V_k;
  250. case __V_m : // "EU"
  251. len = lstrlen(stem);
  252. inheosa = new char [len+1];
  253. for (i = 0; i < len; i++)
  254. inheosa [i] = stem [len-1-i];
  255. inheosa [i] = '\0';
  256. if (FindIrrWord(inheosa, _IV_DP) & FINAL || // TIEUT irregular light verb (V2+)
  257. FindIrrWord(inheosa, _IV_DM) & FINAL) // TIEUT irregular dark verb (V2-)
  258. {
  259. stem [0] = __K_R;
  260. }
  261. return COMPOSED;
  262. default : return COMPOSE_ERROR;
  263. }
  264. }
  265. return COMPOSED;
  266. }
  267. return NOT_COMPOSED;
  268. }
  269. int Compose_SIOS_Irregular (char *stem, char *ending)
  270. {
  271. int len, i;
  272. char *inheosa;
  273. if (stem [0] == __K_S)
  274. {
  275. if (ending [0] == __K_I)
  276. {
  277. switch (ending [1])
  278. {
  279. case __V_j : // "EO"
  280. if (CheckRightMostStemVowel (stem)) // vowel harmony
  281. ending [1] = __V_k;
  282. case __V_m : // "EU"
  283. len = lstrlen(stem);
  284. inheosa = new char [len+1];
  285. for (i = 0; i < len; i++)
  286. inheosa [i] = stem [len-1-i];
  287. inheosa [i] = '\0';
  288. if (FindIrrWord(inheosa, _IV_SP) & FINAL || // SIOS irregular light verb (V2+)
  289. FindIrrWord(inheosa, _IV_SM) & FINAL) // SIOS irregular dark verb (V2-)
  290. {
  291. memmove (stem, stem+1, lstrlen(stem)); // remove SIOS
  292. }
  293. return COMPOSED;
  294. default : return COMPOSE_ERROR;
  295. }
  296. }
  297. return COMPOSED;
  298. }
  299. return NOT_COMPOSED;
  300. }
  301. BOOL Compose_YEO_Irregular (char *stem, char *ending)
  302. {
  303. if (stem [0] == __K_H && stem [1] == __V_k) // The last of stem is "HA"
  304. {
  305. if (ending [0] == __K_I && ending [1] == __V_m) // The first of ending is "EU"
  306. memmove (ending, ending + 2, lstrlen (ending+1)); // remove "IEUNG, EU"
  307. if (ending [0] == __K_I && ending [1] == __V_j)
  308. {
  309. memmove (stem, stem+1, lstrlen (stem)); // remove "A" : the last letter of stem
  310. // "IEUNG, EO" --> "AE"
  311. memmove (ending, ending+1, lstrlen (ending));
  312. ending [0] = __V_o;
  313. }
  314. return TRUE;
  315. }
  316. return FALSE;
  317. }
  318. void Compose_EU_Irregular (char *stem, char *ending)
  319. {
  320. int len = lstrlen(stem);
  321. char * inheosa = new char [len+1];
  322. for (int i = 0; i < len; i++)
  323. inheosa [i] = stem [len-1-i];
  324. inheosa [i] = '\0';
  325. if (FindIrrWord(inheosa, _IV_OmP) & FINAL || // EU irregular light verb (V8+)
  326. FindIrrWord(inheosa, _IA_OmP) & FINAL || // EU irregular light adjective (A8+)
  327. FindIrrWord(inheosa, _IV_OmM) & FINAL || // EU irregular dark verb (V8-)
  328. FindIrrWord(inheosa, _IA_OmM) & FINAL) // EU irregular dark adjective (A8-)
  329. {
  330. if (ending [0] == __K_I && ending [1] == __V_j)
  331. {
  332. if (CheckRightMostStemVowel (stem)) // vowel harmony
  333. ending [1] = __V_k;
  334. memmove (stem, stem+1, lstrlen(stem));
  335. memmove (ending, ending+1, lstrlen(ending));
  336. }
  337. }
  338. }
  339. BOOL Compose_REO_REU_Irregular (char *stem, char *ending)
  340. {
  341. if (stem [0] == __V_m) // The last letter of stem is "EU"
  342. {
  343. int len = lstrlen(stem);
  344. char * inheosa = new char [len+1];
  345. for (int i = 0; i < len; i++)
  346. inheosa [i] = stem [len-1-i];
  347. inheosa [i] = '\0';
  348. if (stem [1] == __K_R)
  349. {
  350. if (FindIrrWord(inheosa, _IV_Rj) & FINAL || // REO irregular verb (V7)
  351. FindIrrWord(inheosa, _IA_Rj) & FINAL) // REO irregular adjective (A7)
  352. {
  353. if (ending [0] == __K_I)
  354. {
  355. switch (ending [1])
  356. {
  357. case __V_j :
  358. ending [0] = __K_R;
  359. break;
  360. case __V_m :
  361. memmove (ending, ending+2, lstrlen(ending+1));
  362. break;
  363. }
  364. }
  365. return TRUE;
  366. }
  367. if (FindIrrWord(inheosa, _IV_RmP) & FINAL || // REU irregular light verb (V6+)
  368. FindIrrWord(inheosa, _IA_RmP) & FINAL || // REU irregular light adjective (A6+)
  369. FindIrrWord(inheosa, _IV_RmM) & FINAL || // REU irregular dark verb (V6-)
  370. FindIrrWord(inheosa, _IA_RmM) & FINAL) // REU irregular dark adjective (A6-)
  371. {
  372. if (ending [0] == __K_I)
  373. {
  374. switch (ending [1])
  375. {
  376. case __V_j :
  377. if (CheckRightMostStemVowel (stem)) // vowel harmony
  378. ending [1] = __V_k;
  379. ending [0] = __K_R;
  380. break;
  381. case __V_m :
  382. memmove (ending, ending+2, lstrlen(ending+1));
  383. break;
  384. }
  385. }
  386. return TRUE;
  387. }
  388. return TRUE;
  389. }
  390. Compose_EU_Irregular (stem, ending);
  391. return TRUE;
  392. }
  393. return FALSE;
  394. }
  395. BOOL Compose_U_Irregular (char *stem, char *ending)
  396. {
  397. if (stem [0] == __K_P && stem [1] == __V_n) // The last of stem is "PU"
  398. {
  399. if (ending [0] == __K_I && ending [1] == __V_m) // The first of ending is "EU"
  400. memmove (ending, ending + 2, lstrlen (ending+1)); // remove "IEUNG, EU"
  401. if (ending [0] == __K_I && ending [1] == __V_j)
  402. {
  403. memmove (stem, stem+1, lstrlen (stem)); // remove "U" : the last letter of stem
  404. memmove (ending, ending+1, lstrlen (ending)); // remove "IEUNG"
  405. }
  406. return TRUE;
  407. }
  408. return FALSE;
  409. }
  410. BOOL Compose_GEORA_Irregular (char *stem, char *ending)
  411. {
  412. if (ending [0] == __K_I && ending [1] == __V_j && ending [2] == __K_R && ending [3] == __V_k) // The last of stem is "GEORA"
  413. {
  414. int len = lstrlen(stem);
  415. char * inheosa = new char [len+1];
  416. for (int i = 0; i < len; i++)
  417. inheosa [i] = stem [len-1-i];
  418. inheosa [i] = '\0';
  419. if (FindIrrWord(inheosa, _IV_Gj) & FINAL) // GEORA irregular verb (V0)
  420. {
  421. ending [0] = __K_G;
  422. return TRUE;
  423. }
  424. if (FindIrrWord(inheosa, _IV_Nj) & FINAL) // NEORA irregular verb (V1)
  425. {
  426. ending [0] = __K_N;
  427. return TRUE;
  428. }
  429. if (CheckRightMostStemVowel (stem)) // vowel harmony
  430. ending [1] = __V_k;
  431. return TRUE;
  432. }
  433. return FALSE;
  434. }
  435. void Contraction (char *stem, char *ending)
  436. {
  437. if (CheckRightMostStemVowel (stem)) // vowel harmony
  438. ending [1] = __V_k;
  439. switch (stem [0])
  440. {
  441. case __V_k : // the last letter of stem is "A"
  442. memmove (ending, ending+2, lstrlen(ending+2));
  443. return;
  444. case __V_j : // the last letter of stem is "EO"
  445. memmove (ending, ending+2, lstrlen(ending+2));
  446. return;
  447. case __V_h :
  448. if (stem [1] == __K_I) // the last character of stem is "O"
  449. {
  450. stem [0] = __V_hk;
  451. memmove (ending, ending+2, lstrlen(ending+1));
  452. }
  453. return;
  454. case __V_n :
  455. stem [0] = __V_nj;
  456. memmove (ending, ending+2, lstrlen(ending+1));
  457. return;
  458. case __V_hl :
  459. if (stem [1] == __K_D) // the last character of stem is "DOE"
  460. {
  461. stem [0] = __V_hl;
  462. memmove (ending, ending+2, lstrlen(ending+1));
  463. }
  464. return;
  465. case __V_l :
  466. if (stem [1] == __K_I)
  467. {
  468. }
  469. }
  470. }
  471. BOOL Compose_Regular (char * stem, char *ending)
  472. {
  473. if (stem [0] < __V_k) // if the last letter of stem is consonant
  474. {
  475. if (ending [0] == __K_I && ending [1] == __V_j) // the first character of ending is "EO"
  476. {
  477. if (CheckRightMostStemVowel (stem)) // vowel harmony
  478. ending [1] = __V_k;
  479. }
  480. return TRUE;
  481. }
  482. if (ending [0] == __K_I && ending [1] == __V_j)
  483. {
  484. if (CheckRightMostStemVowel (stem)) // vowel harmony
  485. ending [1] = __V_k;
  486. Contraction (stem, ending);
  487. return TRUE;
  488. }
  489. if (ending [0] == __K_I && ending [1] == __V_m)
  490. memmove (ending, ending + 2, lstrlen (ending+1));
  491. return TRUE;
  492. }