Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use levensthein distance to propose verbs when encountering unknown verb #16

Open
ModernRonin opened this issue Oct 16, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ModernRonin
Copy link
Owner

No description provided.

@ModernRonin ModernRonin added enhancement New feature or request good first issue Good for newcomers labels Oct 16, 2020
@victormarante
Copy link
Contributor

victormarante commented Mar 21, 2022

I made a quick test implementation of this, following this formula (https://wikimedia.org/api/rest_v1/media/math/render/svg/6224efffbe9a4e01afbddeeb900bfd1b3350b335). Should probably reside in HelpAndErrorInterpreter

private int CalculateLevenstheinDistance(string source, string target)
    {
        var sourceLength = source.Length;
        var targetLength = target.Length;

        if (targetLength == 0) return sourceLength;
        if (sourceLength == 0) return targetLength;

        if (source.First() == target.First())
        {
            return CalculateLevenstheinDistance(source.Substring(1), target.Substring(1));
        }

        return new[]
        {
            CalculateLevenstheinDistance(source[1..], target),
            CalculateLevenstheinDistance(source, target[1..]),
            CalculateLevenstheinDistance(source[1..], target[1..]),
        }.Min() + 1;
    }

@ModernRonin ModernRonin changed the title Use levensthein distance for to propose verbs when encountering unknown verb Use levensthein distance to propose verbs when encountering unknown verb Mar 27, 2022
@ModernRonin
Copy link
Owner Author

ModernRonin commented Mar 27, 2022

very cool! Did you try it out with a few verbs slightly misspelt? does it have the intended effect?
If yes, do you want to integrate it? HelpAndErrorInterpreter sounds like a good place.

@ModernRonin
Copy link
Owner Author

also, seeing as you are very active, I was wondering whether you would like to take a look at the issues marked as "needs design" and give your thoughts, first from a usability perspective (how would a developer want to use it and how should a user of the app being build experience/use it)?

@victormarante
Copy link
Contributor

Hi! I will definitely look at it. I will start a new job next Friday, so my time might be limited. But I will surely take a look at it.

@victormarante
Copy link
Contributor

very cool! Did you try it out with a few verbs slightly misspelt? does it have the intended effect?

If yes, do you want to integrate it? HelpAndErrorInterpreter sounds like a good place.

Hi. I do have more testing on a local branch. Will commit and create a pull request showing what I got this far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants