# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="zyWse8DcM8B-"
# # Installation

# + colab={"base_uri": "https://localhost:8080/"} id="DE3hAzVBFk8a" outputId="5b8df402-0917-4741-c8e4-08c8ec33fa9e"
# !pip install polyfuzz[all]

# + [markdown] id="PxwexpFfM_Xy"
# # Imports

# + id="sCwdotFGM--P"
from polyfuzz import PolyFuzz
from polyfuzz.models import Embeddings
from flair.embeddings import TransformerWordEmbeddings

# + [markdown] id="qa8be5uPNEGe"
# # Edit Distance based Similarity Score

# + id="Lkg937M1FpoM"
list_1 = ["apple", "amazon", "google"]
list_2 = ["search", "juice", "forest"]

# + colab={"base_uri": "https://localhost:8080/"} id="nBWVLPEOIH71" outputId="77c36460-c7fb-4ee5-d4b8-518255a17890"
model = PolyFuzz("EditDistance")
model.match(list_1, list_2)

# + colab={"base_uri": "https://localhost:8080/", "height": 141} id="ui_ExaFpGU8Z" outputId="d600f4e9-4d1c-4645-ab19-68c4733dd69c"
model.get_matches()

# + [markdown] id="CZimfpXENIm3"
# # Bert Based Similarity

# + id="q1Lcfvf4GpQy"
embeddings = TransformerWordEmbeddings('bert-base-multilingual-cased')
bert = Embeddings(embeddings)

# + colab={"base_uri": "https://localhost:8080/"} id="n9PfvfSPGzRF" outputId="928c7cd8-d186-4acb-f810-d125e5d3fc39"
bert_model = PolyFuzz(bert)
bert_model.match(list_1, list_2)

# + colab={"base_uri": "https://localhost:8080/", "height": 141} id="WzNu4gV6G1Tl" outputId="7d284939-14da-4df8-f5a0-dccffa9e058b"
bert_model.get_matches()

StarcoderdataJupyterScriptsDedupFiltered