How do auto-correction algorithms work in PHP and / or C #?

I am trying to understand how auto-correction algorithms can be implemented in either PHP or C# .

In short, I have a user-entered word that should allow the transfer of minor spelling errors. I also have a SQL correctly spelled words. I want to be able to capture the closest (correctly) recorded word from the database to what the user entered.

I understand that there are zillion auto-correction packages, but I would like to be able to customize it, so I am looking for any information about the implementation of this function in PHP or C# .

Thanks a lot, Brett

+4
source share
3 answers

I assume that you are referring to Peter Norwig's spell corrector , only written in C # or PHP ( 1 , 2 ) related to his site.

This is the method that Google uses to correct spelling.

+6
source

Dictionary file and levenshtein distance functions will be your best choice.

http://us.php.net/manual/en/function.levenshtein.php

Check out the comments on this feature; it has several implementation examples.

To go to the next level, you can also add soundex or metaphone functions there, as well as catch phonetic errors.

+2
source

Web or windows? Suppose the web as you mention PHP.

Budget or no budget? There are various web editors. Telerik does good AJAX control, for example, which allows you to use AJAX for spell checking. It is fully customizable. I am sure that some of the other vendors (Infragistics, Synfusion, ComponentOne, etc.) have similar editors.

If you need to go to Open Source, there are editors. However, I’m not sure what support lists customization. Since third-party controls are relatively inexpensive (a few hundred dollars or less) and easily customizable (Telerik), I think this is the best option for encoding yourself or completing an open source implementation that is hard to set up. However, it's worth looking at open source.

0
source

Source: https://habr.com/ru/post/1337831/


All Articles