Skip to content

TufayelLUS/Find-Closely-Matched-Words-In-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Find Closely Matched Words In Python

This repository contains template code to find closely matched words from a list of words

Introduction

Often we face cases where we have different words to process and consider similar words as the same. An example situation can be a comparison of the data obtained from two different websites where the data can slightly vary from one another. This template should help to get an idea of how to handle those cases using fuzzywuzzy library and Levenshtein distance algorithm.

Example

Let's assume that we have two lists of words

[
    "mercedez",
    "toyota supra",
    "bmw"
]

and

[
    "Mercedez benz",
    "supra",
    "bmw"
]

Here, you can see that the words mercedez and Mercedez benz are both similar to one another. And they're the same company. To compare and consider them as the same data, this template approach will be useful. If you have two words already known instead of a list, you may simply do this:

from fuzzywuzzy import fuzz
accuracy_ratio = 80
word1 = "mercedez"
word2 = "Mercedez benz"
if fuzz.partial_ratio(word1, word2) > accuracy_ratio:
    print("Matched")
else:
    print("Not matched)

And that will do the trick.

Command

pip install fuzzywuzzy python-Levenshtein

Need a software developer to automate your tasks?

Contact Me on Fiverr | Contact Me on LinkedIn | Contact Me on Facebook

About

This repository contains template code to find closely matched words from a list of words

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages