Refactored string similarity