{"id":491,"date":"2015-12-20T15:14:59","date_gmt":"2015-12-20T12:14:59","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=491"},"modified":"2015-12-26T09:34:45","modified_gmt":"2015-12-26T06:34:45","slug":"soundex-algorithm","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=491","title":{"rendered":"soundEx algorithm"},"content":{"rendered":"<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0444\u043e\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u0445<\/h2>\n<p>\u0424\u043e\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b &#8212; \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0434\u0432\u0443\u043c \u0441\u043b\u043e\u0432\u0430\u043c \u0441\u043e \u0441\u0445\u043e\u0436\u0438\u043c \u043f\u0440\u043e\u0438\u0437\u043d\u043e\u0448\u0435\u043d\u0438\u0435\u043c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043a\u043e\u0434\u044b, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0445 \u0444\u043e\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0445\u043e\u0434\u0441\u0442\u0432\u0430. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0444\u043e\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: NYSIIS, Metaphone, Double Metaphone, Caverphone \u0438 \u0442.\u0434.  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043e\u0442\u0447\u0451\u0442\u0435 \u044f \u043d\u0430\u043f\u0438\u0448\u0443 \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0444\u043e\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f  soundEx.<br \/>\nsoundEx &#8212; \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0420\u043e\u0431\u0435\u0440\u0442\u043e\u043c \u0420\u0430\u0441\u0441\u0435\u043b\u043e\u043c \u0438 \u041c\u0430\u0440\u0433\u0430\u0440\u0435\u0442 \u041a\u0438\u043d\u0433 \u041e\u0434\u0435\u043b\u043b \u0432 10-\u0445 \u0433\u043e\u0434\u0430\u0445 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0432\u0435\u043a\u0430. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0442\u0430\u043b \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u044b\u043b \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d \u0432 \u043a\u043d\u0438\u0433\u0435 \u0414\u043e\u043d\u0430\u043b\u044c\u0434\u0430 \u041a\u043d\u0443\u0442\u0430 &#171;\u0418\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f&#187;.<\/p>\n<h2>soundEx<\/h2>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\u041a\u043e\u0434<\/td>\n<td>\u0421\u043b\u043e\u0432\u043e<\/td>\n<\/tr>\n<tr>\n<td>a500<\/td>\n<td>ammonium<\/td>\n<\/tr>\n<tr>\n<td>i514<\/td>\n<td>implementation<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u0414\u0430\u043d\u043d\u044b\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432\u0438\u0434\u0430 <b>LNNN(Q123)<\/b> \u0441\u043b\u043e\u0432\u0443. \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443:<\/p>\n<ul>\n<li>\u041f\u0435\u0440\u0432\u0430\u044f \u0431\u0443\u043a\u0432\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f<\/li>\n<li>\u0412\u0441\u0435 \u0433\u043b\u0430\u0441\u043d\u044b\u0435 \u0437\u0432\u0443\u043a\u0438 + \u0431\u0443\u043a\u0432\u044b h, w \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f <\/li>\n<li>\u041e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0431\u0443\u043a\u0432\u044b \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0446\u0438\u0444\u0440\u0430\u043c\u0438 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 1 \u0434\u043e 6 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c:<br \/>\n<table>\n<tbody>\n<tr>\n<td>B, P, F, V<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>C, S, K, G, J, Q, X, Z<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>D, T<\/td>\n<td>3<\/td>\n<\/tr>\n<tr>\n<td>L<\/td>\n<td>4<\/td>\n<\/tr>\n<tr>\n<td>M, N<\/td>\n<td>5<\/td>\n<\/tr>\n<tr>\n<td>R<\/td>\n<td>6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0437 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0446\u0438\u0444\u0440 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u043a\u043e\u0439 \u0446\u0438\u0444\u0440\u043e\u0439<\/li>\n<li>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u0442\u0441\u044f \u0434\u043e \u043f\u0435\u0440\u0432\u044b\u0445 4-\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 4\u0445, \u0442\u043e \u0432 \u043a\u043e\u043d\u0435\u0446 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0443\u043b\u0438.<\/li>\n<\/ul>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440:<\/h3>\n<p>javalanguage \u2192 jvlngg \u2192  j214522 \u2192 j21452 \u2192 j214<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<\/h2>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f soundEx \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0432\u044b\u0448\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443.<br \/>\n\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c HashMap, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043e \u043a\u043b\u044e\u0447\u0443-\u0438\u043d\u0434\u0435\u043a\u0441\u0443 soundEx \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043b\u043e\u0432, \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e\u0434 \u044d\u0442\u043e\u0442 \u043a\u043b\u044e\u0447.<\/p>\n<pre class=\"lang:java decode:true \">import java.util.*;\r\nimport java.lang.*;\r\nimport java.io.*;\r\n\r\nclass Codechef {\r\n\tpublic static String soundEx (String a){\r\n\t\tint n = a.length();\r\n\t\tchar [] sdx = a.toUpperCase().toCharArray();\r\n\t\tchar fl = sdx[0];\r\n\t\tfor (int i = 0 ; i &lt; n; i++){\r\n\t\t\tswitch(sdx[i]) {\r\n\t\t\t\tcase 'B' :\r\n\t\t\t\tcase 'P' :\r\n\t\t\t\tcase 'F' :\r\n\t\t\t\tcase 'V' :\r\n\t\t\t\t\tsdx[i] = '1';\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'C':\r\n\t\t\t\tcase 'S':\r\n\t\t\t\tcase 'K':\r\n\t\t\t\tcase 'G':\r\n\t\t\t\tcase 'J':\r\n\t\t\t\tcase 'Q':\r\n\t\t\t\tcase 'X':\r\n\t\t\t\tcase 'Z':\r\n\t\t\t\t\tsdx[i] = '2';\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'D':\r\n\t\t\t\tcase 'T':\r\n\t\t\t\t\tsdx[i] = '3';\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'L':\r\n\t\t\t\t\tsdx[i] = '4';\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'M':\r\n\t\t\t\tcase 'N':\r\n\t\t\t\t\tsdx[i] = '5';\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'R' :\r\n\t\t\t\t\tsdx[i] = '6';\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault: \r\n\t\t\t\t\tsdx[i] = '0';\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\tString retSdx = \"\" + fl;\r\n\t\tfor (int i = 0; i &lt; sdx.length; i++){\r\n\t\t\tif (sdx[i] != '0') {\r\n\t\t\t\tretSdx += sdx[i];\r\n\t\t\t}\r\n\t\t}\r\n\t\tString ans = \"\"+fl;\r\n\t\tfor (int i = 1; i &lt; retSdx.length(); i++){\r\n\t\t\tif (retSdx.charAt(i) != (retSdx.charAt(i-1))) {\r\n\t\t\t\tans += retSdx.charAt(i);\r\n\t\t\t}\r\n\t\t}\r\n\t\tans = ans + \"0000\";\r\n\t\treturn ans.substring(0, 4);\r\n\t}\r\n\tpublic static void main (String[] args) {\r\n\t\tMap &lt;String, List&lt;String&gt; &gt; words = new HashMap&lt;String, List&lt;String&gt; &gt; ();\r\n\t\tScanner in = new Scanner (System.in);\r\n\t\tString input = in.nextLine();\r\n\t\tinput = \" \" + input;\r\n\t\tString [] t = input.split(\" \");\r\n\t\tfor (int i = 1; i &lt; t.length; i++) {\r\n\t\t\tList&lt;String&gt; L = words.get(soundEx(t[i]));\r\n\t    \tif (L == null)\r\n\t\t\t\twords.put(soundEx(t[i]), L=new ArrayList&lt;String&gt;());\r\n\t\t\tL.add(t[i]);\r\n\t\t}\r\n\t\tfor (Object x : words.keySet()){\r\n\t\t\tSystem.out.print(x + \": \");\r\n\t\t\tList&lt;String&gt; L = words.get(x);\r\n\t\t\tfor (Object y : L) System.out.print(y + \" \");\r\n\t\t\tSystem.out.println();\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<p><a href=\"https:\/\/ideone.com\/BOQgTx\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 Ideone<\/a><\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440:<\/h3>\n<p><strong>In:<\/strong> Dedlovskiy Dedlovskih Nasimov Nagimov Zazimov Azazimov Marchenko Merchenko Dedlovich Nagiev Houston Watson<br \/>\n<strong>Out:<\/strong><br \/>\nN521: Nagiev<br \/>\nD341: Dedlovskiy Dedlovskih Dedlovich<br \/>\nA251: Azazimov<br \/>\nM562: Marchenko Merchenko<br \/>\nW325: Watson<br \/>\nZ251: Zazimov<br \/>\nH235: Houston<br \/>\nN525: Nasimov Nagimov <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0444\u043e\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u0445 \u0424\u043e\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b &#8212; \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0434\u0432\u0443\u043c \u0441\u043b\u043e\u0432\u0430\u043c \u0441\u043e \u0441\u0445\u043e\u0436\u0438\u043c \u043f\u0440\u043e\u0438\u0437\u043d\u043e\u0448\u0435\u043d\u0438\u0435\u043c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043a\u043e\u0434\u044b, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0445 \u0444\u043e\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0445\u043e\u0434\u0441\u0442\u0432\u0430. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0444\u043e\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: NYSIIS, Metaphone, Double Metaphone, Caverphone \u0438 \u0442.\u0434. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043e\u0442\u0447\u0451\u0442\u0435 \u044f \u043d\u0430\u043f\u0438\u0448\u0443 \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0444\u043e\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=491\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[55,57,56],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/491"}],"collection":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=491"}],"version-history":[{"count":1,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/491\/revisions"}],"predecessor-version":[{"id":497,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/491\/revisions\/497"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}