Returns the similarity of string1 and string2 as a number between 0.0 and 1.0, using LEVENSHTEIN edit distance or DICE coefficient.
(string1, string2, metric=LEVENSHTEIN)
| 286 | |
| 287 | LEVENSHTEIN, DICE = "levenshtein", "dice" |
| 288 | def similarity(string1, string2, metric=LEVENSHTEIN): |
| 289 | """ Returns the similarity of string1 and string2 as a number between 0.0 and 1.0, |
| 290 | using LEVENSHTEIN edit distance or DICE coefficient. |
| 291 | """ |
| 292 | if metric == LEVENSHTEIN: |
| 293 | return levenshtein_similarity(string1, string2) |
| 294 | if metric == DICE: |
| 295 | return dice_coefficient(string1, string2) |
| 296 | |
| 297 | #--- STRING READABILITY ---------------------------------------------------------------------------- |
| 298 | # 0.9-1.0 = easily understandable by 11-year old. |
nothing calls this directly
no test coverage detected
searching dependent graphs…