Skip to content

Instantly share code, notes, and snippets.

@flodolo
Created September 12, 2024 11:16
Show Gist options
  • Save flodolo/1e5572d98476d267ea878bccd1d6e96d to your computer and use it in GitHub Desktop.
Save flodolo/1e5572d98476d267ea878bccd1d6e96d to your computer and use it in GitHub Desktop.
Test python-levenshtein vs RapidFuzz
import Levenshtein
from rapidfuzz.distance import Indel
sentence_pairs = (
("The sky is blue.", "It looks like rain."),
("I love reading books.", "My favorite genre is fantasy."),
("She enjoys playing piano.", "He prefers the guitar."),
("Coffee wakes me up.", "Tea relaxes me."),
("We are going to the park.", "They are staying home."),
("The dog barked loudly.", "The cat quietly meowed."),
("It's a sunny day.", "Tomorrow might be cloudy."),
("She danced gracefully.", "He watched from the sidelines."),
("I need to buy groceries.", "Do we have enough milk?"),
("The flowers are blooming.", "The trees are full of leaves."),
("I finished my homework.", "Now I can play video games."),
("The car needs a wash.", "It rained last night."),
("He wrote a letter.", "She replied with an email."),
("I enjoy long walks.", "They prefer running."),
("The movie was exciting.", "The ending surprised me."),
("She baked a cake.", "He made the frosting."),
("The sun sets at six.", "The stars will be out soon."),
("I'm learning French.", "He speaks Spanish."),
("She has a pet rabbit.", "He has a goldfish."),
("The pizza smells delicious.", "The pasta looks amazing."),
("I like your hat.", "Thanks, it’s new."),
("We took a train.", "They flew by plane."),
("The project is due tomorrow.", "I still need to finish it."),
("The beach was crowded.", "We found a quiet spot."),
("He sings beautifully.", "She plays the violin."),
("I lost my keys.", "They were under the couch."),
("She rides her bike daily.", "He prefers walking."),
("The cake is chocolate.", "The icing is vanilla."),
("We saw a movie.", "They went to a concert."),
("The sky turned orange.", "The sun was setting."),
("He forgot his wallet.", "She paid for dinner."),
("I need a new phone.", "My screen is cracked."),
("She bought a new dress.", "He got a new jacket."),
("The cat is sleeping.", "The dog is barking."),
("I enjoy painting.", "She likes to draw."),
("We went hiking.", "They stayed home."),
("The weather is nice.", "It might rain tomorrow."),
("He made breakfast.", "She brewed coffee."),
("I read a book.", "They watched a documentary."),
("She took a nap.", "He worked on his project."),
("The road was empty.", "The town was quiet."),
("I ordered a salad.", "She had the soup."),
("We listened to music.", "They danced all night."),
("He took a photo.", "She smiled at the camera."),
("I need more time.", "The deadline is close."),
("She called her friend.", "He sent a text."),
("The room was warm.", "I opened the window."),
("The stars were bright.", "We stayed up late."),
("I made a mistake.", "I'll try again tomorrow."),
("She gave me a gift.", "I was really surprised."),
("The clock struck midnight.", "It was a new day."),
("We watched the sunset.", "The sky turned pink."),
("The soup is hot.", "Be careful not to burn your mouth."),
("He won the game.", "She congratulated him."),
("I need a haircut.", "My hair is too long."),
("The door was locked.", "I forgot my keys."),
("She loves ice cream.", "Chocolate is her favorite."),
("We planted a tree.", "It will grow tall."),
("I left my bag.", "It was on the table."),
("The sky was clear.", "We could see the stars."),
("He gave a speech.", "The audience clapped."),
("She bought flowers.", "They were for her mother."),
("We visited a museum.", "They learned a lot."),
("The river was calm.", "The boat drifted slowly."),
("I finished the puzzle.", "It took me hours."),
("She started a new job.", "He wished her luck."),
("The cake was delicious.", "Everyone wanted seconds."),
("The sun is shining.", "It’s a beautiful day."),
("He found his wallet.", "It was in his jacket."),
("She wrote a poem.", "It was very touching."),
("The road was bumpy.", "We drove carefully."),
("We booked a flight.", "The tickets were on sale."),
("He played the piano.", "She sang along."),
("The tree is tall.", "It provides a lot of shade."),
("She loves to travel.", "He enjoys staying home."),
("The soup needs salt.", "The bread is perfect."),
("We took a taxi.", "The traffic was light."),
("He joined the team.", "They welcomed him."),
("She painted the wall.", "The color is bright."),
("The lights went out.", "We lit some candles."),
("He baked cookies.", "They smelled amazing."),
("She bought a book.", "He got a magazine."),
("The concert was loud.", "We had a great time."),
("The sky turned gray.", "A storm was coming."),
("He won the race.", "She came in second."),
("The coffee is cold.", "I'll make a fresh pot."),
("We went for a swim.", "The water was cool."),
("He told a joke.", "Everyone laughed."),
("The car is fast.", "It accelerates quickly."),
("She brought snacks.", "They were delicious."),
("I need new shoes.", "Mine are worn out."),
("The beach was beautiful.", "The waves were calm."),
("She found her ring.", "It was under the bed."),
("The birds are chirping.", "It’s early in the morning."),
("He cleaned the kitchen.", "It looks spotless now."),
("The flowers are wilting.", "I forgot to water them."),
("She missed the bus.", "He offered her a ride."),
("The snow is falling.", "It’s so peaceful."),
("He loves playing chess.", "She prefers checkers."),
("The moon is full.", "It's shining brightly."),
("I packed my suitcase.", "We're leaving tomorrow."),
("She built a sandcastle.", "The tide washed it away."),
("He learned a new song.", "She listened with delight."),
("We found a shortcut.", "It saved us a lot of time."),
("The lake was frozen.", "We went ice skating."),
("She forgot her password.", "He helped her reset it."),
("The fire was warm.", "We sat close to it."),
("The night was quiet.", "We heard only the wind."),
("He opened the door.", "She stepped inside."),
("We took a photo.", "It came out beautifully."),
("The garden is blooming.", "The flowers are colorful."),
("He solved the puzzle.", "She was impressed."),
("The book was long.", "It took me weeks to finish."),
("She drew a picture.", "It was very detailed."),
("The wind was strong.", "It blew away my hat."),
("He cooked dinner.", "It was very tasty."),
("We caught the last train.", "It was nearly empty."),
("The sun is setting.", "The sky is turning orange."),
("She played the violin.", "He accompanied on the piano."),
("The cake is ready.", "Let’s eat!"),
("He found a stray cat.", "She gave it some food."),
("We rented a car.", "It’s very comfortable."),
("The hotel was full.", "We had to find another."),
("She gave a presentation.", "The audience asked questions."),
("We rode our bikes.", "It was a sunny afternoon."),
("He went for a jog.", "She stayed home to rest."),
("The leaves are falling.", "Autumn is here."),
("She adopted a dog.", "It’s very playful."),
("We played a game.", "It was a close match."),
("The coffee was bitter.", "I added some sugar."),
("He fixed the computer.", "It’s working now."),
("She took a photo.", "It came out great."),
("We visited a zoo.", "The animals were amazing."),
("The pizza was hot.", "We waited for it to cool."),
("He missed his flight.", "He had to rebook."),
("She taught a class.", "The students were attentive."),
("We built a snowman.", "It melted the next day."),
("The library was quiet.", "I found a good book."),
("He wrote a poem.", "She read it out loud."),
("We set up a tent.", "It was a windy night."),
("The music was loud.", "We had to shout to talk."),
("She painted a picture.", "It’s hanging on the wall."),
("The path was rocky.", "We hiked carefully."),
("We played cards.", "I won the last round."),
("The fish swam quickly.", "The water was clear."),
("She hosted a party.", "Everyone had a great time."),
("The bread is fresh.", "It smells wonderful."),
("We baked a pie.", "It’s still cooling."),
("The clouds are dark.", "It might rain soon."),
("He opened a gift.", "It was just what he wanted."),
("She made a sandwich.", "It was very filling."),
("We took a boat ride.", "The lake was calm."),
("The dog was barking.", "We brought it inside."),
("She sang a song.", "Her voice was beautiful."),
("He took a photo.", "It captured the moment perfectly."),
("We cleaned the house.", "It looks spotless now."),
("The moon is rising.", "It’s a clear night."),
("She picked a flower.", "It was her favorite color."),
("He solved the riddle.", "She was amazed."),
("We went to the movies.", "The film was fantastic."),
("The rain was heavy.", "We stayed inside."),
("He bought a gift.", "It was for his friend."),
("She planted flowers.", "They’ll bloom in the spring."),
("We visited a friend.", "It was a nice afternoon."),
("He found a treasure.", "It was buried in the sand."),
("The sunset was beautiful.", "We took lots of pictures."),
("She read a book.", "It was very engaging."),
("We cooked dinner.", "It turned out great."),
("The car was fast.", "It sped down the highway."),
("He learned to juggle.", "She clapped in amazement."),
("We went swimming.", "The water was warm."),
("She played the piano.", "The melody was lovely."),
("The cat chased the mouse.", "It was a quick chase."),
("We built a fire.", "It kept us warm."),
("The book was interesting.", "I couldn’t put it down."),
("She bought a new hat.", "It looked great on her."),
("We walked in the park.", "The weather was perfect."),
("He made a sculpture.", "It was very intricate."),
("We played a board game.", "It was a lot of fun."),
("The rain stopped.", "The sun came out."),
("She painted her nails.", "They looked shiny."),
("He fixed the sink.", "It stopped leaking."),
("We visited a farm.", "The animals were friendly."),
("She found her glasses.", "They were on the shelf."),
("The fire was crackling.", "We sat around it."),
("He brewed some coffee.", "It smelled wonderful."),
("She took a nap.", "She felt refreshed."),
("We played in the snow.", "It was so much fun."),
("The street was busy.", "Cars were honking."),
("He learned to cook.", "His dishes are delicious."),
("We watched a play.", "The actors were amazing."),
("The ice cream melted.", "We ate it quickly."),
("She planted a tree.", "It will grow tall."),
("The sky is clear.", "You can see the stars."),
("He sang a song.", "Everyone clapped."),
("We played soccer.", "It was a great game."),
("The lake was calm.", "We went fishing."),
("She wrote a story.", "It was very creative."),
("The stars are shining.", "It's a beautiful night."),
("We roasted marshmallows.", "They were delicious."),
("The cake is ready.", "Let’s slice it."),
("He found a key.", "It opened the door."),
("She made a blanket.", "It’s very warm."),
("We walked on the beach.", "The sand was soft."),
("The rain was light.", "We didn't need umbrellas."),
("He built a house.", "It took months."),
("She bought a bike.", "It’s brand new."),
("We danced all night.", "The music was great."),
("He grew a garden.", "The vegetables are ready to harvest."),
("She cooked dinner.", "It was delicious."),
("We went to a fair.", "The rides were fun."),
("The book was long.", "I finally finished it."),
("She took a walk.", "It was a peaceful evening."),
("The sky is pink.", "The sun is setting."),
("He bought a car.", "It’s very fast."),
("We found a shell.", "It was shiny."),
("She wrote a poem.", "It was beautiful."),
("The cake is cooling.", "We’ll eat it soon."),
("He bought a gift.", "It was wrapped nicely."),
("We watched a show.", "It was entertaining."),
("She made a salad.", "It was healthy."),
("The cat is sleeping.", "It’s curled up."),
("We cleaned the garage.", "It looks much better now."),
("He fixed the fence.", "It’s sturdy again."),
("She played the flute.", "The music was soothing."),
("The car was dirty.", "We washed it."),
("We went camping.", "It was an adventure."),
("She found a coin.", "It looked old."),
("He baked a cake.", "It smelled delicious."),
("We took a boat ride.", "The water was calm."),
("The sun is rising.", "It’s a new day."),
("She cooked breakfast.", "It was ready on time."),
("We built a fort.", "It was cozy inside."),
("The street was empty.", "It was early morning."),
("He drew a picture.", "It was very detailed."),
("She found a feather.", "It was colorful."),
("We went skiing.", "The snow was perfect."),
("The stars are twinkling.", "It’s a clear night."),
("He learned to swim.", "Now he loves the water."),
("She planted flowers.", "They are blooming."),
("We cooked dinner.", "It was a feast."),
("The wind is strong.", "It’s blowing leaves around."),
("He bought new shoes.", "They fit perfectly."),
("She baked cookies.", "They were delicious."),
("We watched the stars.", "The sky was clear."),
("The dog is barking.", "It heard something."),
("He read a book.", "It was very interesting."),
("She made a cake.", "It’s for the party."),
("We went for a hike.", "The view was amazing."),
("The cake is done.", "Let’s eat it now."),
("He found a hat.", "It’s his favorite color."),
("She drew a picture.", "It was beautiful."),
("We played a game.", "It was very fun."),
("The rain is stopping.", "The sun is coming out."),
("He played a song.", "It was on the piano."),
("We went to the park.", "The weather was nice."),
("She made a bracelet.", "It was very colorful."),
("The dog was excited.", "It wagged its tail."),
("He took a nap.", "Now he feels better."),
("We cooked dinner.", "It smells great."),
("The movie was long.", "But it was interesting."),
("She wrote a letter.", "It was very thoughtful."),
("He fixed the car.", "Now it runs smoothly."),
("We played a game.", "I won the last round."),
("The sun is setting.", "The sky is orange."),
("She took a photo.", "It turned out perfect."),
("The street is quiet.", "It’s late at night."),
("We visited a museum.", "The exhibits were fascinating."),
("He found a dollar.", "It was on the sidewalk."),
("She made a sandwich.", "It was delicious."),
("The sky is clear.", "It’s a perfect day."),
("He built a fire.", "It kept us warm."),
("We went swimming.", "The water was cool."),
("She sang a song.", "Her voice was beautiful."),
("The car is fast.", "It drives smoothly."),
("We walked home.", "It was a short distance."),
("The cake is ready.", "We can eat it now."),
("He drew a picture.", "It was very detailed."),
("She made breakfast.", "It was ready on time."),
("We went to the beach.", "The waves were calm."),
("The stars are shining.", "The night is clear."),
("He bought a car.", "It’s very fast."),
("We took a trip.", "It was very relaxing."),
("The rain is falling.", "The ground is wet."),
("She baked cookies.", "They smelled delicious."),
("He won the game.", "She congratulated him."),
("We watched a show.", "It was very funny."),
("The sky is blue.", "It’s a beautiful day."),
("She drew a picture.", "It was very colorful."),
("He made a cake.", "It’s for his friend."),
("We played a game.", "It was very exciting."),
("The sun is shining.", "It’s a perfect day."),
("She sang a song.", "Her voice was lovely."),
("The dog is barking.", "It heard something."),
("He wrote a letter.", "It was very thoughtful."),
("We went on a hike.", "The view was breathtaking."),
("The rain is stopping.", "The clouds are clearing."),
("She made a scarf.", "It’s very warm."),
("He fixed the bike.", "Now it rides smoothly."),
("We baked a pie.", "It’s cooling now."),
("The stars are bright.", "It’s a clear night."),
("She took a photo.", "It turned out great."),
("He found a coin.", "It looked very old."),
("We played soccer.", "It was a fun match."),
("The cake is done.", "Let’s eat it now."),
("She spent hours painting the sunset, blending the colors until it looked just like the one she saw the night before.",
"Her work was meticulous, and the final result captured the beauty of the moment perfectly."),
("The new software update promised to fix the bugs that had been plaguing the system for weeks.",
"However, after installation, users reported even more issues than before."),
("He had planned the surprise party for weeks, making sure everything was perfect for her big day.",
"When she walked in and saw all her friends gathered, her reaction was worth all the effort."),
("The conference was filled with industry experts, all eager to share their insights on the latest trends.",
"By the end of the event, she had a notebook full of ideas to take back to her team."),
("They had always dreamed of owning a small cottage by the lake, surrounded by trees and nature.",
"After years of saving, they finally made that dream a reality."),
("The detective followed the clues meticulously, each one leading him closer to the truth.",
"But the final piece of evidence would prove to be the most unexpected of all."),
("She stared out the airplane window, watching the clouds drift by as she thought about the adventure awaiting her.",
"It was her first solo trip, and excitement mixed with nervousness filled her."),
("The hike through the dense forest was challenging, with uneven terrain and hidden roots.",
"But the breathtaking view at the top made every difficult step worth it."),
("He loved experimenting in the kitchen, always trying out new recipes and ingredients.",
"This time, his creation was a success, and everyone at the table couldn't stop raving about the flavors."),
("The old bookstore was her favorite place to escape, with its cozy reading nooks and the smell of aged paper.",
"Every visit felt like stepping into another world full of stories waiting to be discovered."),
("The storm outside was raging, with howling winds and torrential rain battering the windows.",
"But inside, the fireplace crackled warmly, and the family gathered for a night of board games."),
("The new project was daunting, with tight deadlines and high expectations from the client.",
"However, the team was determined to deliver something exceptional, and they worked day and night to achieve it."),
("They had trained for months for this marathon, waking up early to run in all types of weather.",
"When they finally crossed the finish line together, it felt like a huge accomplishment."),
("The mystery novel she was reading had so many twists and turns, it was hard to predict what would happen next.",
"Each chapter ended with a cliffhanger that made it impossible to put the book down."),
("The small bakery on the corner was famous for its fresh pastries, especially the chocolate croissants.",
"Every morning, a line would form out the door, with people eager to get their hands on the treats."),
("The city park was alive with activity, from joggers making their morning rounds to children playing on the swings.",
"It was the perfect place to relax and soak in the fresh air on a weekend."),
("His collection of vintage watches was impressive, each one telling a story of craftsmanship and history.",
"He would often spend hours polishing them, making sure they were in perfect working condition."),
("She had always loved photography, capturing moments that others might overlook in the hustle and bustle of daily life.",
"Her latest project focused on the little details, like the way sunlight hit the leaves on a tree."),
("The research paper had taken months to complete, with countless hours spent in the library and at the computer.",
"But seeing it finally published in a reputable journal made all the hard work worthwhile."),
("The family reunion was a lively affair, with relatives flying in from all over the country to catch up and share memories.",
"By the end of the weekend, they had taken hundreds of photos to remember the occasion."),
("The new restaurant in town was gaining a reputation for its creative dishes and bold flavors.",
"Every meal felt like an adventure, with unique combinations that left diners wanting more."),
("He had been practicing his speech for weeks, standing in front of the mirror to make sure his delivery was perfect.",
"When the big day arrived, his nerves melted away as he spoke with confidence and clarity."),
("The exhibit at the museum featured stunning works of art from local artists, each piece telling a unique story.",
"Visitors wandered through the galleries, admiring the creativity and talent on display."),
("She always enjoyed working in the garden, planting flowers and watching them bloom throughout the season.",
"This year, her roses were particularly vibrant, drawing compliments from all her neighbors."),
("The train ride through the countryside was peaceful, with rolling hills and fields of flowers stretching out in every direction.",
"As they passed small villages, she snapped pictures of the charming scenes."),
("The concert had been sold out for months, with fans eager to see their favorite band perform live.",
"As the lights dimmed and the first notes rang out, the crowd erupted in cheers."),
("They had been best friends since childhood, sharing countless memories and inside jokes over the years.",
"Even though they lived far apart now, they still made time to talk regularly."),
("The charity event was a huge success, raising more money than they had anticipated for the local animal shelter.",
"At the end of the night, they were already planning next year's fundraiser."),
("The family road trip was full of laughs, music, and pit stops at quirky roadside attractions.",
"By the time they reached their destination, they had enough stories to last a lifetime."),
("The old mansion had been abandoned for years, its once-grand halls now filled with dust and cobwebs.",
"But to the new owner, it was full of potential, and she could already envision restoring it to its former glory."),
("The soccer game was intense, with both teams fighting hard for the win as the clock ticked down.",
"In the final moments, a last-minute goal secured the victory."),
("The school play was a hit, with the students delivering a performance that was full of energy and enthusiasm.",
"The proud parents in the audience gave them a standing ovation."),
("The summer festival was in full swing, with food vendors, live music, and games for people of all ages.",
"The highlight of the day was the fireworks show that lit up the night sky."),
("The local coffee shop had a cozy atmosphere, with soft lighting, comfy chairs, and the smell of freshly brewed coffee.",
"It quickly became her go-to spot for reading and relaxing."),
("The storm had knocked out the power, leaving the house in darkness except for the light of a few flickering candles.",
"They huddled together under blankets, waiting for the lights to come back on."),
("The mountain trail was steep and rocky, but the view from the summit made the difficult hike worth it.",
"Standing at the top, they felt like they were on top of the world."),
("The chess match between the two grandmasters had the audience on the edge of their seats, with every move analyzed and debated.",
"In the end, a brilliant strategy led to a checkmate."),
("The scent of freshly baked bread filled the kitchen, making everyone’s mouths water as they waited for it to cool.",
"When it was finally time to slice it, the soft interior and crunchy crust were perfection."),
("The family had always gathered at the cabin by the lake for their annual summer vacation, spending the days swimming and fishing.",
"This year, they introduced a new tradition: a campfire storytelling night."),
("The science fair was a huge event, with students presenting projects that ranged from volcano models to solar-powered robots.",
"The judges were impressed by the creativity and innovation on display."),
("The town was famous for its annual harvest festival, where locals showcased their best produce, crafts, and homemade goods.",
"Visitors from surrounding areas came to enjoy the festivities."),
("The local theater group put on a fantastic performance of a classic play, drawing in crowds night after night.",
"By the final show, tickets had sold out."),
("They had planned the road trip for months, mapping out every stop and attraction along the way.",
"When the day finally arrived, they loaded up the car and set off on their adventure."),
("The beach was quiet as the sun began to rise, casting a soft pink glow over the water.",
"She sat on the sand, enjoying the peaceful start to the day."),
("The small town was known for its beautiful gardens, with flowers blooming in every yard and along the streets.",
"Each year, they held a contest to see who had the most impressive display."),
("The office was buzzing with excitement as the team prepared for the product launch, their hard work finally coming to fruition.",
"When the orders started coming in, they knew they had created something special."),
("The ice cream shop was a popular hangout spot in the summer, with its long list of unique flavors and outdoor seating.",
"On warm evenings, families and friends would gather there to cool off."),
("The artist had spent weeks working on her latest painting, carefully blending colors and adding tiny details.",
"When it was finally finished, she stepped back and admired her creation."),
("The fishing trip had been a great success, with each member of the group catching something by the end of the day.",
"As they packed up their gear, they swapped stories about the ones that got away."),
("The carnival was filled with the sound of laughter and the smell of popcorn, with rides spinning and games beckoning from every corner.",
"By the end of the night, they had won enough prizes to fill the backseat of their car."),
)
errors = False
for pair in sentence_pairs:
old_score = round(Levenshtein.ratio(pair[0], pair[1]) * 100)
new_score = round((1 - Indel.normalized_distance(pair[0], pair[1])) * 100)
if old_score != new_score:
errors = True
print(f"\n-----\nDifference:")
print(f"Sentence 1: {pair[0]}")
print(f"Sentence 2: {pair[1]}")
print(f"Old score: {old_score}")
print(f"New score: {new_score}")
if not errors:
print("No errors.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment