def worddistance(source, target):
''' Return the Levenshtein distance between 2 strings '''
if len(source) > len(target):
source, target = target, source
#Now target becomes the larger string, if it is 0, surely len(source) is 0?
if len(target) == 0:
return len(source)
### Continue on to calculate distance.
두 매개 변수가 동일하면 0을 반환하는 것과 똑같지 않습니까?Levenshtein 거리 알고리즘
나는 함수의이 부분의 길이가 0입니다 당신은 거의Wikibooks implementation에서 같은 스타일을 볼 수 있습니다 둘 경우
가
예, 코드가 모두 길이 0 인 경우 코드는 '0'을 반환합니다. –
@MartijnPieters 다른 작업을 수행하는지 확실하지 않습니다. 그렇지 않다면, 나는 그것을 단순하게 할 것입니다. –