class Levenshtein: #ここで配列を立ち上げて、初期値を入れる def initArray(self,str1,str2): distance = [] for i in range(len(str1)+1): distance.append([0]*(len(str2)+1)) distance[i][0] = i for j in range(len(str2)+1): distance[0][j] = j return distance #セルに値を入れる def editDist(self,str1,str2,distance): dist = [0]*3 for i in range(1,len(str1)+1): for j in range(1,len(str2)+1): dist[0] = distance[i-1][j-1] if str1[i-1]==s
![編集距離についての説明及びPythonでの実装 - Qiita](https://cdn-ak-scissors.b.st-hatena.com/image/square/0a31d2ac48ee65c59941d4934da399679b6ad13d/height=288;version=1;width=512/https%3A%2F%2Fqiita-user-contents.imgix.net%2Fhttps%253A%252F%252Fcdn.qiita.com%252Fassets%252Fpublic%252Farticle-ogp-background-412672c5f0600ab9a64263b751f1bc81.png%3Fixlib%3Drb-4.0.0%26w%3D1200%26mark64%3DaHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZ3PTk3MiZoPTM3OCZ0eHQ9JUU3JUI3JUE4JUU5JTlCJTg2JUU4JUI3JTlEJUU5JTlCJUEyJUUzJTgxJUFCJUUzJTgxJUE0JUUzJTgxJTg0JUUzJTgxJUE2JUUzJTgxJUFFJUU4JUFBJUFDJUU2JTk4JThFJUU1JThGJThBJUUzJTgxJUIzUHl0aG9uJUUzJTgxJUE3JUUzJTgxJUFFJUU1JUFFJTlGJUU4JUEzJTg1JnR4dC1hbGlnbj1sZWZ0JTJDdG9wJnR4dC1jb2xvcj0lMjMyMTIxMjEmdHh0LWZvbnQ9SGlyYWdpbm8lMjBTYW5zJTIwVzYmdHh0LXNpemU9NTYmcz04NTIxNWYwZDU4M2E3MTFmOGQwMjg0YWUxOTZiMmQ2ZA%26mark-x%3D142%26mark-y%3D57%26blend64%3DaHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZoPTc2Jnc9NzcwJnR4dD0lNDB0ZW50ZW4xMDEwJnR4dC1jb2xvcj0lMjMyMTIxMjEmdHh0LWZvbnQ9SGlyYWdpbm8lMjBTYW5zJTIwVzYmdHh0LXNpemU9MzYmdHh0LWFsaWduPWxlZnQlMkN0b3Amcz0wYzE3YjkxYzRhMGUwMzZiNmQzMDcwYmZlNDJjN2NmOA%26blend-x%3D142%26blend-y%3D486%26blend-mode%3Dnormal%26s%3D4c9cc598cee17a52bc04eb22ad9df81e)