What algorithm/library to convert the word typed in the wrong layout?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/code-flow.club/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
36 views
In fact, to do what Punto Switcher. You need to constantly convert similar errors made in different languages not using the Latin alphabet. Preferably in Python, can PHP.
by | 36 views

7 Answers

0 like 0 dislike
by
0 like 0 dislike
Here's an outline of what I proposed:
\r
\r
<?php\r\r$layouts['en'] = preg_split('!!u', 'qwertyuiop[]asdfghjkl;\\'\\zxcvbnm,./', null, PREG_SPLIT_NO_EMPTY);\r$layouts['ru'] = preg_split('!!u', 'йцукенгшщзхъфывапролджэ\\ячсмитьбю.', null, PREG_SPLIT_NO_EMPTY);\r\r\r$phrase = "тестовая cnhjrf с неверной раскладкой\";\recho $phrase;\r\r$phrase_chunks = explode(' ', $phrase);\r$ch = array();\rforeach ($phrase_chunks as $phrase_chunk) $curl_handles[] = curl_init();\r\rforeach ($curl_handles as $index => $curl_handle) { curl_setopt($curl_handle, CURLOPT_URL, "http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q=".urlencode($phrase_chunks[$index])); curl_setopt($curl_handle, CURLOPT_HEADER, false); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true); } $mh = curl_multi_init(); foreach ($curl_handles as $index => $curl_handle) { curl_multi_add_handle($mh, $curl_handle); } $active = null; do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); while ($active && $mrc == CURLM_OK) { if (curl_multi_select($mh) != -1) { do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); } } foreach ($curl_handles as $index => $curl_handle) { $responses[] = json_decode(curl_multi_getcontent($curl_handle)); } foreach ($curl_handles as $index => $curl_handle) { curl_multi_remove_handle($mh, $curl_handle); } curl_multi_close($mh); foreach ($responses as $index => $response) { if ($response->responseData->confidence <= 0.005 && $response->responseData->language != 'EN') { $phrase_chunks[$index] = str_replace($layouts['en'], $layouts['EN'], $phrase_chunks[$index]); } } echo implode(' ', $phrase_chunks)."\"; ?> 
by
0 like 0 dislike
Split into words and passed on to the search Google, if the answer is "maybe you was looking for..." — use it :)
by
0 like 0 dislike
Neural network. They are the images of the nuts clicked.
by
0 like 0 dislike
In fact, if several languages, but still no English... just sleep on it. Perhaps really should look in the direction of the trained systems, the finished solution will be hard to find IMHO
by
0 like 0 dislike
Maybe this?
$ aptitude show enca
...
Description: heuristic encoding detection
Enca (Extremely Naive Charset Analyser) determines the most probable encoding of these text files. You can also convert files in the specified encoding (the built-in tools or external tools, for example: libiconv, librecode, cstocs).
Currently supported: Belarusian, Bulgarian, Croatian, Czech, Estonian, Hungarian, Latvian, Lithuanian, Polish, Russian, Slovak, Slovenian, Ukrainian, Chinese, as well as the definition of multi-byte encodings regardless of the language.
Website: gitorious.org/enca
\r
by
0 like 0 dislike
by
110,608 questions
257,186 answers
0 comments
23,592 users