PageRenderTime 52ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/modules/analysis/kuromoji/src/java/org/apache/lucene/analysis/kuromoji/util/ToStringUtil.java

http://github.com/apache/lucene-solr
Java | 1023 lines | 981 code | 10 blank | 32 comment | 367 complexity | a5c4e7f943c7c95bc1f1b920a7efb55c MD5 | raw file
Possible License(s): LGPL-2.1, CPL-1.0, MPL-2.0-no-copyleft-exception, JSON, Apache-2.0, AGPL-1.0, GPL-2.0, GPL-3.0, MIT, BSD-3-Clause
  1. package org.apache.lucene.analysis.kuromoji.util;
  2. /**
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. import java.util.HashMap;
  19. public class ToStringUtil {
  20. // a translation map for parts of speech, only used for reflectWith
  21. private static final HashMap<String,String> posTranslations = new HashMap<String,String>();
  22. static {
  23. posTranslations.put("??", "noun");
  24. posTranslations.put("??-??", "noun-common");
  25. posTranslations.put("??-????", "noun-proper");
  26. posTranslations.put("??-????-??", "noun-proper-misc");
  27. posTranslations.put("??-????-??", "noun-proper-person");
  28. posTranslations.put("??-????-??-??", "noun-proper-person-misc");
  29. posTranslations.put("??-????-??-?", "noun-proper-person-surname");
  30. posTranslations.put("??-????-??-?", "noun-proper-person-given_name");
  31. posTranslations.put("??-????-??", "noun-proper-organization");
  32. posTranslations.put("??-????-??", "noun-proper-place");
  33. posTranslations.put("??-????-??-??", "noun-proper-place-misc");
  34. posTranslations.put("??-????-??-?", "noun-proper-place-country");
  35. posTranslations.put("??-???", "noun-pronoun");
  36. posTranslations.put("??-???-??", "noun-pronoun-misc");
  37. posTranslations.put("??-???-??", "noun-pronoun-contraction");
  38. posTranslations.put("??-????", "noun-adverbial");
  39. posTranslations.put("??-????", "noun-verbal");
  40. posTranslations.put("??-??????", "noun-adjective-base");
  41. posTranslations.put("??-?", "noun-numeric");
  42. posTranslations.put("??-???", "noun-affix");
  43. posTranslations.put("??-???-??", "noun-affix-misc");
  44. posTranslations.put("??-???-????", "noun-affix-adverbial");
  45. posTranslations.put("??-???-?????", "noun-affix-aux");
  46. posTranslations.put("??-???-??????", "noun-affix-adjective-base");
  47. posTranslations.put("??-??", "noun-special");
  48. posTranslations.put("??-??-?????", "noun-special-aux");
  49. posTranslations.put("??-??", "noun-suffix");
  50. posTranslations.put("??-??-??", "noun-suffix-misc");
  51. posTranslations.put("??-??-??", "noun-suffix-person");
  52. posTranslations.put("??-??-??", "noun-suffix-place");
  53. posTranslations.put("??-??-????", "noun-suffix-verbal");
  54. posTranslations.put("??-??-?????", "noun-suffix-aux");
  55. posTranslations.put("??-??-??????", "noun-suffix-adjective-base");
  56. posTranslations.put("??-??-????", "noun-suffix-adverbial");
  57. posTranslations.put("??-??-???", "noun-suffix-classifier");
  58. posTranslations.put("??-??-??", "noun-suffix-special");
  59. posTranslations.put("??-????", "noun-suffix-conjunctive");
  60. posTranslations.put("??-??????", "noun-verbal_aux");
  61. posTranslations.put("??-?????", "noun-quotation");
  62. posTranslations.put("??-???????", "noun-nai_adjective");
  63. posTranslations.put("???", "prefix");
  64. posTranslations.put("???-????", "prefix-nominal");
  65. posTranslations.put("???-????", "prefix-verbal");
  66. posTranslations.put("???-?????", "prefix-adjectival");
  67. posTranslations.put("???-???", "prefix-numerical");
  68. posTranslations.put("??", "verb");
  69. posTranslations.put("??-??", "verb-main");
  70. posTranslations.put("??-???", "verb-auxiliary");
  71. posTranslations.put("??-??", "verb-suffix");
  72. posTranslations.put("???", "adjective");
  73. posTranslations.put("???-??", "adjective-main");
  74. posTranslations.put("???-???", "adjective-auxiliary");
  75. posTranslations.put("???-??", "adjective-suffix");
  76. posTranslations.put("??", "adverb");
  77. posTranslations.put("??-??", "adverb-misc");
  78. posTranslations.put("??-?????", "adverb-particle_conjunction");
  79. posTranslations.put("???", "adnominal");
  80. posTranslations.put("???", "conjunction");
  81. posTranslations.put("??", "particle");
  82. posTranslations.put("??-???", "particle-case");
  83. posTranslations.put("??-???-??", "particle-case-misc");
  84. posTranslations.put("??-???-??", "particle-case-quote");
  85. posTranslations.put("??-???-??", "particle-case-compound");
  86. posTranslations.put("??-????", "particle-conjunctive");
  87. posTranslations.put("??-???", "particle-dependency");
  88. posTranslations.put("??-???", "particle-adverbial");
  89. posTranslations.put("??-????", "particle-interjective");
  90. posTranslations.put("??-????", "particle-coordinate");
  91. posTranslations.put("??-???", "particle-final");
  92. posTranslations.put("??-????????????", "particle-adverbial/conjunctive/final");
  93. posTranslations.put("??-???", "particle-adnominalizer");
  94. posTranslations.put("??-???", "particle-adnominalizer");
  95. posTranslations.put("??-??", "particle-special");
  96. posTranslations.put("???", "auxiliary-verb");
  97. posTranslations.put("???", "interjection");
  98. posTranslations.put("??", "symbol");
  99. posTranslations.put("??-??", "symbol-misc");
  100. posTranslations.put("??-??", "symbol-period");
  101. posTranslations.put("??-??", "symbol-comma");
  102. posTranslations.put("??-??", "symbol-space");
  103. posTranslations.put("??-???", "symbol-open_bracket");
  104. posTranslations.put("??-???", "symbol-close_bracket");
  105. posTranslations.put("??-???????", "symbol-alphabetic");
  106. posTranslations.put("???", "other");
  107. posTranslations.put("???-??", "other-interjection");
  108. posTranslations.put("????", "filler");
  109. posTranslations.put("????", "non-verbal");
  110. posTranslations.put("???", "fragment");
  111. posTranslations.put("???", "unknown");
  112. }
  113. /**
  114. * Get the english form of a POS tag
  115. */
  116. public static String getPOSTranslation(String s) {
  117. return posTranslations.get(s);
  118. }
  119. // a translation map for inflection types, only used for reflectWith
  120. private static final HashMap<String,String> inflTypeTranslations = new HashMap<String,String>();
  121. static {
  122. inflTypeTranslations.put("*", "*");
  123. inflTypeTranslations.put("????????", "adj-group-a-o-u");
  124. inflTypeTranslations.put("??????", "adj-group-i");
  125. inflTypeTranslations.put("??????", "adj-group-ii");
  126. inflTypeTranslations.put("????", "non-inflectional");
  127. inflTypeTranslations.put("????", "special-da");
  128. inflTypeTranslations.put("????", "special-ta");
  129. inflTypeTranslations.put("??????", "classical-gotoshi");
  130. inflTypeTranslations.put("?????", "special-ja");
  131. inflTypeTranslations.put("?????", "special-nai");
  132. inflTypeTranslations.put("???????", "5-row-cons-r-special");
  133. inflTypeTranslations.put("????", "special-nu");
  134. inflTypeTranslations.put("????", "classical-ki");
  135. inflTypeTranslations.put("?????", "special-tai");
  136. inflTypeTranslations.put("?????", "classical-beshi");
  137. inflTypeTranslations.put("????", "special-ya");
  138. inflTypeTranslations.put("?????", "classical-maji");
  139. inflTypeTranslations.put("?????", "2-row-lower-cons-t");
  140. inflTypeTranslations.put("?????", "special-desu");
  141. inflTypeTranslations.put("?????", "special-masu");
  142. inflTypeTranslations.put("???????", "5-row-aru");
  143. inflTypeTranslations.put("?????", "classical-nari");
  144. inflTypeTranslations.put("????", "classical-ri");
  145. inflTypeTranslations.put("?????", "classical-keri");
  146. inflTypeTranslations.put("????", "classical-ru");
  147. inflTypeTranslations.put("????????", "5-row-cons-k-i-onbin");
  148. inflTypeTranslations.put("?????", "5-row-cons-s");
  149. inflTypeTranslations.put("??", "1-row");
  150. inflTypeTranslations.put("????????", "5-row-cons-w-cons-onbin");
  151. inflTypeTranslations.put("?????", "5-row-cons-m");
  152. inflTypeTranslations.put("?????", "5-row-cons-t");
  153. inflTypeTranslations.put("?????", "5-row-cons-r");
  154. inflTypeTranslations.put("??????", "irregular-suffix-suru");
  155. inflTypeTranslations.put("?????", "5-row-cons-g");
  156. inflTypeTranslations.put("??????", "irregular-suffix-zuru");
  157. inflTypeTranslations.put("?????", "5-row-cons-b");
  158. inflTypeTranslations.put("????????", "5-row-cons-w-u-onbin");
  159. inflTypeTranslations.put("?????", "2-row-lower-cons-d");
  160. inflTypeTranslations.put("??????????", "5-row-cons-k-cons-onbin-yuku");
  161. inflTypeTranslations.put("?????", "2-row-upper-cons-d");
  162. inflTypeTranslations.put("????????", "5-row-cons-k-cons-onbin");
  163. inflTypeTranslations.put("?????", "1-row-eru");
  164. inflTypeTranslations.put("?????", "4-row-cons-t");
  165. inflTypeTranslations.put("?????", "5-row-cons-n");
  166. inflTypeTranslations.put("?????", "2-row-lower-cons-h");
  167. inflTypeTranslations.put("?????", "4-row-cons-h");
  168. inflTypeTranslations.put("?????", "4-row-cons-b");
  169. inflTypeTranslations.put("?????", "irregular-suru");
  170. inflTypeTranslations.put("?????", "2-row-upper-cons-h");
  171. inflTypeTranslations.put("?????", "2-row-lower-cons-m");
  172. inflTypeTranslations.put("?????", "4-row-cons-s");
  173. inflTypeTranslations.put("?????", "2-row-lower-cons-g");
  174. inflTypeTranslations.put("?????", "kuru-kanji");
  175. inflTypeTranslations.put("??????", "1-row-kureru");
  176. inflTypeTranslations.put("????", "2-row-lower-u");
  177. inflTypeTranslations.put("?????", "kuru-kana");
  178. inflTypeTranslations.put("??", "irregular-cons-r");
  179. inflTypeTranslations.put("?????", "2-row-lower-cons-k");
  180. }
  181. /**
  182. * Get the english form of inflection type
  183. */
  184. public static String getInflectionTypeTranslation(String s) {
  185. return inflTypeTranslations.get(s);
  186. }
  187. // a translation map for inflection forms, only used for reflectWith
  188. private static final HashMap<String,String> inflFormTranslations = new HashMap<String,String>();
  189. static {
  190. inflFormTranslations.put("*", "*");
  191. inflFormTranslations.put("???", "base");
  192. inflFormTranslations.put("?????", "classical-base");
  193. inflFormTranslations.put("?????", "imperfective-nu-connection");
  194. inflFormTranslations.put("?????", "imperfective-u-connection");
  195. inflFormTranslations.put("?????", "conjunctive-ta-connection");
  196. inflFormTranslations.put("?????", "conjunctive-te-connection");
  197. inflFormTranslations.put("???????", "conjunctive-gozai-connection");
  198. inflFormTranslations.put("????", "uninflected-connection");
  199. inflFormTranslations.put("???", "subjunctive");
  200. inflFormTranslations.put("???", "imperative-e");
  201. inflFormTranslations.put("?????", "conditional-contracted-1");
  202. inflFormTranslations.put("?????", "conditional-contracted-2");
  203. inflFormTranslations.put("????", "garu-connection");
  204. inflFormTranslations.put("???", "imperfective");
  205. inflFormTranslations.put("???", "conjunctive");
  206. inflFormTranslations.put("?????", "onbin-base");
  207. inflFormTranslations.put("?????", "conjunctive-de-connection");
  208. inflFormTranslations.put("????", "imperfective-special");
  209. inflFormTranslations.put("???", "imperative-i");
  210. inflFormTranslations.put("?????", "conjunctive-ni-connection");
  211. inflFormTranslations.put("????", "imperative-yo");
  212. inflFormTranslations.put("??????", "adnominal-special");
  213. inflFormTranslations.put("????", "imperative-ro");
  214. inflFormTranslations.put("???????", "uninflected-special-connection-2");
  215. inflFormTranslations.put("??????", "imperfective-reru-connection");
  216. inflFormTranslations.put("?????", "modern-base");
  217. inflFormTranslations.put("???-???", "base-onbin"); // not sure about this
  218. }
  219. /**
  220. * Get the english form of inflected form
  221. */
  222. public static String getInflectedFormTranslation(String s) {
  223. return inflFormTranslations.get(s);
  224. }
  225. /**
  226. * Romanize katakana with modified hepburn
  227. */
  228. public static String getRomanization(String s) {
  229. StringBuilder builder = new StringBuilder();
  230. final int len = s.length();
  231. for (int i = 0; i < len; i++) {
  232. // maximum lookahead: 3
  233. char ch = s.charAt(i);
  234. char ch2 = (i < len - 1) ? s.charAt(i + 1) : 0;
  235. char ch3 = (i < len - 2) ? s.charAt(i + 2) : 0;
  236. main: switch (ch) {
  237. case '?':
  238. switch (ch2) {
  239. case '?':
  240. case '?':
  241. case '?':
  242. case '?':
  243. case '?':
  244. builder.append('k');
  245. break main;
  246. case '?':
  247. case '?':
  248. case '?':
  249. case '?':
  250. case '?':
  251. builder.append('s');
  252. break main;
  253. case '?':
  254. case '?':
  255. case '?':
  256. case '?':
  257. case '?':
  258. builder.append('t');
  259. break main;
  260. case '?':
  261. case '?':
  262. case '?':
  263. case '?':
  264. case '?':
  265. builder.append('p');
  266. break main;
  267. }
  268. break;
  269. case '?':
  270. builder.append('a');
  271. break;
  272. case '?':
  273. if (ch2 == '?') {
  274. builder.append("yi");
  275. i++;
  276. } else if (ch2 == '?') {
  277. builder.append("ye");
  278. i++;
  279. } else {
  280. builder.append('i');
  281. }
  282. break;
  283. case '?':
  284. switch(ch2) {
  285. case '?':
  286. builder.append("wa");
  287. i++;
  288. break;
  289. case '?':
  290. builder.append("wi");
  291. i++;
  292. break;
  293. case '?':
  294. builder.append("wu");
  295. i++;
  296. break;
  297. case '?':
  298. builder.append("we");
  299. i++;
  300. break;
  301. case '?':
  302. builder.append("wo");
  303. i++;
  304. break;
  305. case '?':
  306. builder.append("wyu");
  307. i++;
  308. break;
  309. default:
  310. builder.append('u');
  311. break;
  312. }
  313. break;
  314. case '?':
  315. builder.append('e');
  316. break;
  317. case '?':
  318. if (ch2 == '?') {
  319. builder.append('?');
  320. i++;
  321. } else {
  322. builder.append('o');
  323. }
  324. break;
  325. case '?':
  326. builder.append("ka");
  327. break;
  328. case '?':
  329. if (ch2 == '?' && ch3 == '?') {
  330. builder.append("ky?");
  331. i += 2;
  332. } else if (ch2 == '?' && ch3 == '?') {
  333. builder.append("ky?");
  334. i += 2;
  335. } else if (ch2 == '?') {
  336. builder.append("kya");
  337. i++;
  338. } else if (ch2 == '?') {
  339. builder.append("kyo");
  340. i++;
  341. } else if (ch2 == '?') {
  342. builder.append("kyu");
  343. i++;
  344. } else if (ch2 == '?') {
  345. builder.append("kye");
  346. i++;
  347. } else {
  348. builder.append("ki");
  349. }
  350. break;
  351. case '?':
  352. switch(ch2) {
  353. case '?':
  354. builder.append("kwa");
  355. i++;
  356. break;
  357. case '?':
  358. builder.append("kwi");
  359. i++;
  360. break;
  361. case '?':
  362. builder.append("kwe");
  363. i++;
  364. break;
  365. case '?':
  366. builder.append("kwo");
  367. i++;
  368. break;
  369. case '?':
  370. builder.append("kwa");
  371. i++;
  372. break;
  373. default:
  374. builder.append("ku");
  375. break;
  376. }
  377. break;
  378. case '?':
  379. builder.append("ke");
  380. break;
  381. case '?':
  382. if (ch2 == '?') {
  383. builder.append("k?");
  384. i++;
  385. } else {
  386. builder.append("ko");
  387. }
  388. break;
  389. case '?':
  390. builder.append("sa");
  391. break;
  392. case '?':
  393. if (ch2 == '?' && ch3 == '?') {
  394. builder.append("sh?");
  395. i += 2;
  396. } else if (ch2 == '?' && ch3 == '?') {
  397. builder.append("sh?");
  398. i += 2;
  399. } else if (ch2 == '?') {
  400. builder.append("sha");
  401. i++;
  402. } else if (ch2 == '?') {
  403. builder.append("sho");
  404. i++;
  405. } else if (ch2 == '?') {
  406. builder.append("shu");
  407. i++;
  408. } else if (ch2 == '?') {
  409. builder.append("she");
  410. i++;
  411. } else {
  412. builder.append("shi");
  413. }
  414. break;
  415. case '?':
  416. if (ch2 == '?') {
  417. builder.append("si");
  418. i++;
  419. } else {
  420. builder.append("su");
  421. }
  422. break;
  423. case '?':
  424. builder.append("se");
  425. break;
  426. case '?':
  427. if (ch2 == '?') {
  428. builder.append("s?");
  429. i++;
  430. } else {
  431. builder.append("so");
  432. }
  433. break;
  434. case '?':
  435. builder.append("ta");
  436. break;
  437. case '?':
  438. if (ch2 == '?' && ch3 == '?') {
  439. builder.append("ch?");
  440. i += 2;
  441. } else if (ch2 == '?' && ch3 == '?') {
  442. builder.append("ch?");
  443. i += 2;
  444. } else if (ch2 == '?') {
  445. builder.append("cha");
  446. i++;
  447. } else if (ch2 == '?') {
  448. builder.append("cho");
  449. i++;
  450. } else if (ch2 == '?') {
  451. builder.append("chu");
  452. i++;
  453. } else if (ch2 == '?') {
  454. builder.append("che");
  455. i++;
  456. } else {
  457. builder.append("chi");
  458. }
  459. break;
  460. case '?':
  461. if (ch2 == '?') {
  462. builder.append("tsa");
  463. i++;
  464. } else if (ch2 == '?') {
  465. builder.append("tsi");
  466. i++;
  467. } else if (ch2 == '?') {
  468. builder.append("tse");
  469. i++;
  470. } else if (ch2 == '?') {
  471. builder.append("tso");
  472. i++;
  473. } else if (ch2 == '?') {
  474. builder.append("tsyu");
  475. i++;
  476. } else {
  477. builder.append("tsu");
  478. }
  479. break;
  480. case '?':
  481. if (ch2 == '?') {
  482. builder.append("ti");
  483. i++;
  484. } else if (ch2 == '?') {
  485. builder.append("tu");
  486. i++;
  487. } else if (ch2 == '?') {
  488. builder.append("tyu");
  489. i++;
  490. } else {
  491. builder.append("te");
  492. }
  493. break;
  494. case '?':
  495. if (ch2 == '?') {
  496. builder.append("t?");
  497. i++;
  498. } else {
  499. builder.append("to");
  500. }
  501. break;
  502. case '?':
  503. builder.append("na");
  504. break;
  505. case '?':
  506. if (ch2 == '?' && ch3 == '?') {
  507. builder.append("ny?");
  508. i += 2;
  509. } else if (ch2 == '?' && ch3 == '?') {
  510. builder.append("ny?");
  511. i += 2;
  512. } else if (ch2 == '?') {
  513. builder.append("nya");
  514. i++;
  515. } else if (ch2 == '?') {
  516. builder.append("nyo");
  517. i++;
  518. } else if (ch2 == '?') {
  519. builder.append("nyu");
  520. i++;
  521. } else if (ch2 == '?') {
  522. builder.append("nye");
  523. i++;
  524. } else {
  525. builder.append("ni");
  526. }
  527. break;
  528. case '?':
  529. builder.append("nu");
  530. break;
  531. case '?':
  532. builder.append("ne");
  533. break;
  534. case '?':
  535. if (ch2 == '?') {
  536. builder.append("n?");
  537. i++;
  538. } else {
  539. builder.append("no");
  540. }
  541. break;
  542. case '?':
  543. builder.append("ha");
  544. break;
  545. case '?':
  546. if (ch2 == '?' && ch3 == '?') {
  547. builder.append("hy?");
  548. i += 2;
  549. } else if (ch2 == '?' && ch3 == '?') {
  550. builder.append("hy?");
  551. i += 2;
  552. } else if (ch2 == '?') {
  553. builder.append("hya");
  554. i++;
  555. } else if (ch2 == '?') {
  556. builder.append("hyo");
  557. i++;
  558. } else if (ch2 == '?') {
  559. builder.append("hyu");
  560. i++;
  561. } else if (ch2 == '?') {
  562. builder.append("hye");
  563. i++;
  564. } else {
  565. builder.append("hi");
  566. }
  567. break;
  568. case '?':
  569. if (ch2 == '?') {
  570. builder.append("fya");
  571. i++;
  572. } else if (ch2 == '?') {
  573. builder.append("fyu");
  574. i++;
  575. } else if (ch2 == '?' && ch3 == '?') {
  576. builder.append("fye");
  577. i+=2;
  578. } else if (ch2 == '?') {
  579. builder.append("fyo");
  580. i++;
  581. } else if (ch2 == '?') {
  582. builder.append("fa");
  583. i++;
  584. } else if (ch2 == '?') {
  585. builder.append("fi");
  586. i++;
  587. } else if (ch2 == '?') {
  588. builder.append("fe");
  589. i++;
  590. } else if (ch2 == '?') {
  591. builder.append("fo");
  592. i++;
  593. } else {
  594. builder.append("fu");
  595. }
  596. break;
  597. case '?':
  598. builder.append("he");
  599. break;
  600. case '?':
  601. if (ch2 == '?') {
  602. builder.append("h?");
  603. i++;
  604. } else if (ch2 == '?') {
  605. builder.append("hu");
  606. i++;
  607. } else {
  608. builder.append("ho");
  609. }
  610. break;
  611. case '?':
  612. builder.append("ma");
  613. break;
  614. case '?':
  615. if (ch2 == '?' && ch3 == '?') {
  616. builder.append("my?");
  617. i += 2;
  618. } else if (ch2 == '?' && ch3 == '?') {
  619. builder.append("my?");
  620. i += 2;
  621. } else if (ch2 == '?') {
  622. builder.append("mya");
  623. i++;
  624. } else if (ch2 == '?') {
  625. builder.append("myo");
  626. i++;
  627. } else if (ch2 == '?') {
  628. builder.append("myu");
  629. i++;
  630. } else if (ch2 == '?') {
  631. builder.append("mye");
  632. i++;
  633. } else {
  634. builder.append("mi");
  635. }
  636. break;
  637. case '?':
  638. builder.append("mu");
  639. break;
  640. case '?':
  641. builder.append("mi");
  642. break;
  643. case '?':
  644. if (ch2 == '?') {
  645. builder.append("m?");
  646. i++;
  647. } else {
  648. builder.append("mo");
  649. }
  650. break;
  651. case '?':
  652. builder.append("ya");
  653. break;
  654. case '?':
  655. builder.append("yu");
  656. break;
  657. case '?':
  658. if (ch2 == '?') {
  659. builder.append("y?");
  660. i++;
  661. } else {
  662. builder.append("yo");
  663. }
  664. break;
  665. case '?':
  666. builder.append("ra");
  667. break;
  668. case '?':
  669. if (ch2 == '?' && ch3 == '?') {
  670. builder.append("ry?");
  671. i += 2;
  672. } else if (ch2 == '?' && ch3 == '?') {
  673. builder.append("ry?");
  674. i += 2;
  675. } else if (ch2 == '?') {
  676. builder.append("rya");
  677. i++;
  678. } else if (ch2 == '?') {
  679. builder.append("ryo");
  680. i++;
  681. } else if (ch2 == '?') {
  682. builder.append("ryu");
  683. i++;
  684. } else if (ch2 == '?') {
  685. builder.append("rye");
  686. i++;
  687. } else {
  688. builder.append("ri");
  689. }
  690. break;
  691. case '?':
  692. builder.append("ru");
  693. break;
  694. case '?':
  695. builder.append("re");
  696. break;
  697. case '?':
  698. if (ch2 == '?') {
  699. builder.append("r?");
  700. i++;
  701. } else {
  702. builder.append("ro");
  703. }
  704. break;
  705. case '?':
  706. builder.append("wa");
  707. break;
  708. case '?':
  709. builder.append("i");
  710. break;
  711. case '?':
  712. builder.append("e");
  713. break;
  714. case '?':
  715. builder.append("o");
  716. break;
  717. case '?':
  718. switch (ch2) {
  719. case '?':
  720. case '?':
  721. case '?':
  722. case '?':
  723. case '?':
  724. case '?':
  725. case '?':
  726. case '?':
  727. case '?':
  728. case '?':
  729. case '?':
  730. case '?':
  731. case '?':
  732. case '?':
  733. case '?':
  734. builder.append('m');
  735. break main;
  736. case '?':
  737. case '?':
  738. case '?':
  739. case '?':
  740. case '?':
  741. case '?':
  742. case '?':
  743. case '?':
  744. builder.append("n'");
  745. break main;
  746. default:
  747. builder.append("n");
  748. break main;
  749. }
  750. case '?':
  751. builder.append("ga");
  752. break;
  753. case '?':
  754. if (ch2 == '?' && ch3 == '?') {
  755. builder.append("gy?");
  756. i += 2;
  757. } else if (ch2 == '?' && ch3 == '?') {
  758. builder.append("gy?");
  759. i += 2;
  760. } else if (ch2 == '?') {
  761. builder.append("gya");
  762. i++;
  763. } else if (ch2 == '?') {
  764. builder.append("gyo");
  765. i++;
  766. } else if (ch2 == '?') {
  767. builder.append("gyu");
  768. i++;
  769. } else if (ch2 == '?') {
  770. builder.append("gye");
  771. i++;
  772. } else {
  773. builder.append("gi");
  774. }
  775. break;
  776. case '?':
  777. switch(ch2) {
  778. case '?':
  779. builder.append("gwa");
  780. i++;
  781. break;
  782. case '?':
  783. builder.append("gwi");
  784. i++;
  785. break;
  786. case '?':
  787. builder.append("gwe");
  788. i++;
  789. break;
  790. case '?':
  791. builder.append("gwo");
  792. i++;
  793. break;
  794. case '?':
  795. builder.append("gwa");
  796. i++;
  797. break;
  798. default:
  799. builder.append("gu");
  800. break;
  801. }
  802. break;
  803. case '?':
  804. builder.append("ge");
  805. break;
  806. case '?':
  807. if (ch2 == '?') {
  808. builder.append("g?");
  809. i++;
  810. } else {
  811. builder.append("go");
  812. }
  813. break;
  814. case '?':
  815. builder.append("za");
  816. break;
  817. case '?':
  818. if (ch2 == '?' && ch3 == '?') {
  819. builder.append("j?");
  820. i += 2;
  821. } else if (ch2 == '?' && ch3 == '?') {
  822. builder.append("j?");
  823. i += 2;
  824. } else if (ch2 == '?') {
  825. builder.append("ja");
  826. i++;
  827. } else if (ch2 == '?') {
  828. builder.append("jo");
  829. i++;
  830. } else if (ch2 == '?') {
  831. builder.append("ju");
  832. i++;
  833. } else if (ch2 == '?') {
  834. builder.append("je");
  835. i++;
  836. } else {
  837. builder.append("ji");
  838. }
  839. break;
  840. case '?':
  841. if (ch2 == '?') {
  842. builder.append("zi");
  843. i++;
  844. } else {
  845. builder.append("zu");
  846. }
  847. break;
  848. case '?':
  849. builder.append("ze");
  850. break;
  851. case '?':
  852. if (ch2 == '?') {
  853. builder.append("z?");
  854. i++;
  855. } else {
  856. builder.append("zo");
  857. }
  858. break;
  859. case '?':
  860. builder.append("da");
  861. break;
  862. case '?':
  863. builder.append("ji");
  864. break;
  865. case '?':
  866. builder.append("zu");
  867. break;
  868. case '?':
  869. if (ch2 == '?') {
  870. builder.append("di");
  871. i++;
  872. } else if (ch2 == '?') {
  873. builder.append("dyu");
  874. i++;
  875. } else {
  876. builder.append("de");
  877. }
  878. break;
  879. case '?':
  880. if (ch2 == '?') {
  881. builder.append("d?");
  882. i++;
  883. } else if (ch2 == '?') {
  884. builder.append("du");
  885. i++;
  886. } else {
  887. builder.append("do");
  888. }
  889. break;
  890. case '?':
  891. builder.append("ba");
  892. break;
  893. case '?':
  894. if (ch2 == '?' && ch3 == '?') {
  895. builder.append("by?");
  896. i += 2;
  897. } else if (ch2 == '?' && ch3 == '?') {
  898. builder.append("by?");
  899. i += 2;
  900. } else if (ch2 == '?') {
  901. builder.append("bya");
  902. i++;
  903. } else if (ch2 == '?') {
  904. builder.append("byo");
  905. i++;
  906. } else if (ch2 == '?') {
  907. builder.append("byu");
  908. i++;
  909. } else if (ch2 == '?') {
  910. builder.append("bye");
  911. i++;
  912. } else {
  913. builder.append("bi");
  914. }
  915. break;
  916. case '?':
  917. builder.append("bu");
  918. break;
  919. case '?':
  920. builder.append("be");
  921. break;
  922. case '?':
  923. if (ch2 == '?') {
  924. builder.append("b?");
  925. i++;
  926. } else {
  927. builder.append("bo");
  928. }
  929. break;
  930. case '?':
  931. builder.append("pa");
  932. break;
  933. case '?':
  934. if (ch2 == '?' && ch3 == '?') {
  935. builder.append("py?");
  936. i += 2;
  937. } else if (ch2 == '?' && ch3 == '?') {
  938. builder.append("py?");
  939. i += 2;
  940. } else if (ch2 == '?') {
  941. builder.append("pya");
  942. i++;
  943. } else if (ch2 == '?') {
  944. builder.append("pyo");
  945. i++;
  946. } else if (ch2 == '?') {
  947. builder.append("pyu");
  948. i++;
  949. } else if (ch2 == '?') {
  950. builder.append("pye");
  951. i++;
  952. } else {
  953. builder.append("pi");
  954. }
  955. break;
  956. case '?':
  957. builder.append("pu");
  958. break;
  959. case '?':
  960. builder.append("pe");
  961. break;
  962. case '?':
  963. if (ch2 == '?') {
  964. builder.append("p?");
  965. i++;
  966. } else {
  967. builder.append("po");
  968. }
  969. break;
  970. case '?':
  971. if (ch2 == '?' && ch3 == '?') {
  972. builder.append("vye");
  973. i+= 2;
  974. } else {
  975. builder.append('v');
  976. }
  977. break;
  978. case '?':
  979. builder.append('a');
  980. break;
  981. case '?':
  982. builder.append('i');
  983. break;
  984. case '?':
  985. builder.append('u');
  986. break;
  987. case '?':
  988. builder.append('e');
  989. break;
  990. case '?':
  991. builder.append('o');
  992. break;
  993. case '?':
  994. builder.append("wa");
  995. break;
  996. case '?':
  997. builder.append("ya");
  998. break;
  999. case '?':
  1000. builder.append("yu");
  1001. break;
  1002. case '?':
  1003. builder.append("yo");
  1004. break;
  1005. case '?':
  1006. break;
  1007. default:
  1008. builder.append(ch);
  1009. }
  1010. }
  1011. return builder.toString();
  1012. }
  1013. }