Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at


hpr4026 :: Using NLP to get better answer options for language learning

Levenshtein distance may help language learning apps improve answer options for better learning.

<< First, < Previous, , Latest >>

Hosted by thompsgj on Monday, 2024-01-08 is flagged as Clean and is released under a CC-BY-SA license.
levenshtein, nlp, language learning, education. 2.
The show is available on the Internet Archive at: https://archive.org/details/hpr4026

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:16:34

general.

Code snippets

Install the Levenshtein package.

>>> pip install levenshtein

Use the Levenshtein package to calculate the edit distance.

>>> import Levenshtein
>>> Levenshtein.distance("cat", "dog")
3
>>> Levenshtein.distance("cat", "can")
1

Install the TheFuzz package.

>>> pip install thefuzz

Use TheFuzz to calculate the similarity ratio.

>>> from thefuzz import fuzz
>>> fuzz.ratio("cat", "dog")
0
>>> fuzz.ratio("cat", "can")
67

Use TheFuzz to calculate the similarity ratio for each item in a list.

>>> from thefuzz import process
>>> options = ["dog", "can"]
>>> process.extract("cat", options, limit=2)
[('can', 67), ('dog', 0)]
>>> process.extract("cat", options, limit=1)
[('can', 67)]
>>> process.extract("cat", options, limit=2, scorer=fuzz.ratio)
[('can', 67), ('dog', 0)]

Other resources


Comments

Subscribe to the comments RSS feed.

Comment #1 posted on 2024-01-10 16:39:22 by norrist

Interesting Topic

Great First Episode. I like how you explain the complex topic.

Comment #2 posted on 2024-01-14 16:48:02 by Dave Morriss

Levenshtein distances

Interesting show!

I thought I'd heard of Levenshtein distances before, as I was listening. Later I remembered that in the university I worked in (I retired 15 years ago), I added this feature to our OpenLDAP directory server. It allowed us to offer a "sounds like" search capability, though it might have been specific to OpenLDAP (I don't think it's a standard capability).

The LDAP server was used by the university's web-based search tool, amongst a whole load of other services.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the letter P in HPR stand for?
Are you a spammer?
Who is the host of this show?
What does HPR mean to you?