code_junkie

Difflib.SequenceMatcher isjunk optional parameter query: how to ignore whitespaces, tabs, empty lines?

Nov 11th, 2011
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. s=difflib.SequenceMatcher(isjunk,text1,text2)
  2. ratio =s.ratio()
  3.  
  4. difflib.SequenceMatcher(lambda x: x in " tn", doc1, doc2).ratio()
  5.  
  6. >>> s=difflib.SequenceMatcher(lambda x: x == 'n', s1, s2)
  7. >>> s.ratio()
  8. 0.94669848846459825
  9.  
  10. >>> s=difflib.SequenceMatcher(lambda x: x in ' n', s1, s2)
  11. >>> s.ratio()
  12. 0.7653142402545744
  13.  
  14. difflib.SequenceMatcher(lambda x: x in " tn", doc1, doc2).ratio()
  15.  
  16. difflib.SequenceMatcher(" tn".__contains__, doc1, doc2).ratio()
Add Comment
Please, Sign In to add comment