Created
July 12, 2010 21:12
-
-
Save mikejs/473066 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Levenshtein Distance: | |
# NLTK: 446.74 usec/call | |
# strfry: 1.86 usec/call | |
import timeit | |
nltk_lev = timeit.Timer(stmt="nltk.metrics.edit_distance('this is a string', 'this is another string')", | |
setup="import nltk.metrics") | |
str_lev = timeit.Timer(stmt="strfry.levenshtein_distance('this is a string', 'this is another string')", | |
setup="import strfry") | |
print "Levenshtein Distance:" | |
print "NLTK: %.2f usec/call" % nltk_lev.timeit() | |
print "strfry: %.2f %f usec/call" % str_lev.timeit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I try to run the code, only to find that the strfry is a C lib.
I try to install it via pip, but failed.
Could you please tell me why? And how could I get the strfry installed to calculate the levenshtein_distance between two strings efficiently?
Thanks very much.