{"id":9756,"date":"2020-06-09T19:40:56","date_gmt":"2020-06-09T10:40:56","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=9756"},"modified":"2020-06-09T19:49:36","modified_gmt":"2020-06-09T10:49:36","slug":"%eb%91%90-%eb%ac%b8%ec%9e%90%ec%97%b4%ea%b0%84%ec%9d%98-%ec%9c%a0%ec%82%ac%eb%8f%84","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=9756","title":{"rendered":"[Java] \ub450 \ubb38\uc790\uc5f4\uac04\uc758 \uc720\uc0ac\ub3c4 \uad6c\ud558\uae30"},"content":{"rendered":"<p>\ub450\uac1c\uc758 \ubb38\uc790\uc5f4\uc774 \uc788\uc744\ub54c, \uc5bc\ub9c8\ub098 \uc720\uc0ac\ud55c\uc9c0\ub97c \ubc31\ubd84\uc728\uc758 \uac1c\ub150\uc778 0~1\uc0ac\uc774\uc758 \uac12\uc73c\ub85c \ud655\uc778\ud560 \uc218 \uc788\uc744\uae4c? \uc989 \ub611\uac19\uc740 \ubb38\uc790\uc5f4\uc774\ub77c\uba74 1\uc744 \uc804\ud600 \ub2e4\ub978 \ubb38\uc790\uc5f4\uc774\ub77c\uba74 0\uc774\ub77c\ub294 \uac12\uc73c\ub85c \ub9d0\uc774\ub2e4. \uad6c\uae00\ub9c1\ud574\ubcf4\ub2c8 edit distance \uacc4\uc0b0\uc744 \ud1b5\ud574 \uc5bb\uc744 \uc218 \uc788\ub2e8\ub2e4. \uac00\uc7a5 \uc77c\ubc18\uc801\uc740 \uad6c\ud604\uccb4\ub294 <a href='https:\/\/en.wikipedia.org\/wiki\/Levenshtein_distance'>Levenshtein\uc758 Distance Algorithm<\/a>\uc774\ub77c\uace0 \ud558\uace0, \uadf8 \uad6c\ud604 \ud568\uc218\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4. (\ucd9c\ucc98:  http:\/\/rosettacode.org\/wiki\/Levenshtein_distance#Java)<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">\r\nprivate double similarity(String s1, String s2) {\r\n    String longer = s1, shorter = s2;\r\n\t\r\n    if (s1.length() < s2.length()) {\r\n        longer = s2; \r\n        shorter = s1;\r\n    }\r\n\t\r\n    int longerLength = longer.length();\r\n    if (longerLength == 0) return 1.0;\r\n\r\n    return (longerLength - editDistance(longer, shorter)) \/ (double) longerLength;\r\n}\r\n\r\nprivate int editDistance(String s1, String s2) {\r\n\ts1 = s1.toLowerCase();\r\n    s2 = s2.toLowerCase();\r\n    int[] costs = new int[s2.length() + 1];\r\n    \r\n    for (int i = 0; i <= s1.length(); i++) {\r\n        int lastValue = i;\r\n        for (int j = 0; j <= s2.length(); j++) {\r\n            if (i == 0) {\r\n            \tcosts[j] = j;\r\n            } else {\r\n                if (j > 0) {\r\n                    int newValue = costs[j - 1];\r\n                    \r\n                    if (s1.charAt(i - 1) != s2.charAt(j - 1)) {\r\n                    \tnewValue = Math.min(Math.min(newValue, lastValue), costs[j]) + 1;\r\n                    }\r\n                    \r\n                    costs[j - 1] = lastValue;\r\n                    lastValue = newValue;\r\n                }\r\n            }\r\n        }\r\n        \r\n        if (i > 0) costs[s2.length()] = lastValue;\r\n    }\r\n    \r\n    return costs[s2.length()];\r\n}\r\n<\/pre>\n<p>\uc0ac\uc6a9\uc740 similarity \ud568\uc218\uc5d0 \ube44\uad50\ud560 \ubb38\uc790\uc5f4 2\uac1c\ub97c \uc9c0\uc815\ud558\uba74 \ube44\uc2b7\ud55c \uc815\ub3c4\uac00 0~1 \uc0ac\uc774\uc758 \uac12\uc73c\ub85c \ubc18\ud658\ub41c\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ub450\uac1c\uc758 \ubb38\uc790\uc5f4\uc774 \uc788\uc744\ub54c, \uc5bc\ub9c8\ub098 \uc720\uc0ac\ud55c\uc9c0\ub97c \ubc31\ubd84\uc728\uc758 \uac1c\ub150\uc778 0~1\uc0ac\uc774\uc758 \uac12\uc73c\ub85c \ud655\uc778\ud560 \uc218 \uc788\uc744\uae4c? \uc989 \ub611\uac19\uc740 \ubb38\uc790\uc5f4\uc774\ub77c\uba74 1\uc744 \uc804\ud600 \ub2e4\ub978 \ubb38\uc790\uc5f4\uc774\ub77c\uba74 0\uc774\ub77c\ub294 \uac12\uc73c\ub85c \ub9d0\uc774\ub2e4. \uad6c\uae00\ub9c1\ud574\ubcf4\ub2c8 edit distance \uacc4\uc0b0\uc744 \ud1b5\ud574 \uc5bb\uc744 \uc218 \uc788\ub2e8\ub2e4. \uac00\uc7a5 \uc77c\ubc18\uc801\uc740 \uad6c\ud604\uccb4\ub294 Levenshtein\uc758 Distance Algorithm\uc774\ub77c\uace0 \ud558\uace0, \uadf8 \uad6c\ud604 \ud568\uc218\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4. (\ucd9c\ucc98: http:\/\/rosettacode.org\/wiki\/Levenshtein_distance#Java) private double similarity(String s1, String s2) { String longer = s1, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=9756\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;[Java] \ub450 \ubb38\uc790\uc5f4\uac04\uc758 \uc720\uc0ac\ub3c4 \uad6c\ud558\uae30&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[60,1],"tags":[],"class_list":["post-9756","post","type-post","status-publish","format-standard","hentry","category-java","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/9756","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9756"}],"version-history":[{"count":5,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/9756\/revisions"}],"predecessor-version":[{"id":9762,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/9756\/revisions\/9762"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9756"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}