H
harryos
hi
I am trying to write a compare method which takes two strings and find
how many characters have changed.
def compare_strings(s1,s2):
pass
text1="goat milk"
text2="cow milk"
print compare_strings(text1,text2)
This must give 3 ,since 3 characters are changed between strings.I was
advised to use levenshtein algorithm ..but then the matrix ops take a
long time for nontrivial strings of say 20000 characters ..Can this
comparison be implemented using difflib module?..I am at a loss as to
how to implement this using difflib .Is there some way I can get the
difference as a number ?
Can somebody help?
thanks
harry
I am trying to write a compare method which takes two strings and find
how many characters have changed.
def compare_strings(s1,s2):
pass
text1="goat milk"
text2="cow milk"
print compare_strings(text1,text2)
This must give 3 ,since 3 characters are changed between strings.I was
advised to use levenshtein algorithm ..but then the matrix ops take a
long time for nontrivial strings of say 20000 characters ..Can this
comparison be implemented using difflib module?..I am at a loss as to
how to implement this using difflib .Is there some way I can get the
difference as a number ?
Can somebody help?
thanks
harry