A
A
Alisa2014-01-24 00:19:53
PHP
Alisa, 2014-01-24 00:19:53

Automatic correction of a string typed in the wrong layout

Good evening:
There is the following task:
To determine that the text in the search form on the site is typed in the wrong layout and automatically translate it into the correct one. Any solution will suit the client - either replace directly in the search form "on the fly" or give results according to the correct option, for example, as yandex.ru/yandsearch?lr=213&text=ytdthyfz+hfcrkflrf
The site runs on shared hosting, install Sphinx or Yandex server it is forbidden.
It is also impossible to use Yandex / Google search directly on the site, the customer is not satisfied with such a solution.
Stupid replacement of some characters with others will not work, because correct words in English should not be replaced.
Found a library for this purpose, code.google.com/p/php-lang-correct, but in words from the commodity base of this online store it does not work quite correctly (KEYBOARD_LAYOUT mode).
For example, "vfif b vtldtlm" is transformed into "vfif b bear", but it should be "Masha and the bear". The query "toy" also does not work, and a bunch of other ones that can be used to search for goods.
Are there any other solutions other than "make a request, if there are no results, transfer to another layout and repeat"?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
Y
Yuri Lobanov, 2014-01-24
@diksi

Try to convince the client of this: the store is not a search engine like google. Why make such difficult decisions for the sake of the dubious convenience of the client, there will be many problems with support, in the case of foreign words and abbreviations in product names. In my opinion, it is better to do this: with an empty query result, offer to search by the result translated to another layout. If the user agrees, display a hint for using programs like Punto Switcher. In the end, the question is convenience, this is not a jamb on the site, but simply a desire to make it more convenient. After all, if a person sees the inscription: nothing was found for your request Vtldtlm, try to find it by Bear ? - he will appreciate the efforts to help anyway.

P
Puma Thailand, 2014-01-24
@opium

The solution is very easy, it is written in a dozen lines in the code
, we search for the entered word, if we find nothing, we search for the word in the reverse scenario, if we find it, we display the results and the word in a different layout, if we do not find it, we display the original word and that nothing was found.

I
Igor Yatsevich, 2014-01-24
@IgoNsk

I did this on one project (the task was also to search by what is entered):
- we break it into words
- we translate each word from the English layout into Russian, and if the original and the translation do not match, we search in the database in both Russian and English.
Those. something like this:
Wholesale fabrics - (fabrics) & (wholesale)
Nrfyb jgnjv - (nrfyb | fabrics) & (jgnjv | wholesale)
Nrfyb wholesale - (nrfyb | fabrics) & (wholesale)

P
Push Pull, 2014-01-24
@deadbyelpy

once used the recipe from this post
, it's all about defining the popular lemmas of the Russian language in the English layout.
"It is also impossible to use Yandex / Google search directly on the site, the customer is not satisfied with such a solution."
Why directly on the site? curl'om it :) and parse the response

N
Nikolai Vasilchuk, 2014-01-24
@Anonym

Maybe the client will arrange a solution just for him? Any Punto Switcher?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question