N
N
Northern Lights2019-07-30 02:04:33
PHP
Northern Lights, 2019-07-30 02:04:33

Any solutions for spell checking?

Hello. Some users write like this:

Rigging works. Works in warehouses and premises. Unloading and loading trucks, containers, wagons. Apartment, office, warehouse, shop moving. Works on floors.
From this flies layout.
Now I can’t predict all situations - how correct it will be to force a space after a period, comma, colon, semicolon. What are the nuances in terms of spelling? Maybe there are libraries that make a readable text out of such trash, removing unnecessary !!!!! punctuation marks and bringing the text back to normal?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xmoonlight, 2019-07-30
@php666

1. Use regex and check for invalid strings of words and punctuation marks inside the text before posting and normalize delimiter tokens.
2. Check the words themselves for valid characters (and their chains), for length limits and for content in the stop list.
source

<?php
$values = array(
    'text???',
    '???text',
    'text???text',
    'text ? ? ? ? ? text'
);

foreach ($values as $original_value) {
    $value = preg_replace('/([?!.:,;]|\s)\1+/', '$1 ', $original_value);
    echo $original_value . "\n" . $value . "\n\n";
}
Result
text???
text? 

???text
? text

text???text
text? text

text ? ? ? ? ? text
text ? text

Here is a lib for the Russian language: Typograph
At the moment, the printer can ...
Обрабатывать тексты в различных кодировках(требуется iconv).
Заменять кавычки на ёлочки.
Склеивать двойные кавычки.
Заменять знак дефиса или два знака дефиса подряд — на знак длинного тире.
Заменять знак дефиса, ограниченный с обоих сторон цифрами — на знак короткого тире.
Заменять множество пробелов или табуляций на один пробел.
Заменять х в выражениях вроде 10x10 на знак умножения.
Исправлять неправильную расстановку запятых.
Разносить неправильно расставленные кавычки.
Вставлять неразрывный пробел после инициалов, сцеплять инициалы.
Делать неразрывными названия организаций и аббревиатуры форм собственности.
Делать неразрывными имя собственное и относящееся к нему сокращение.
Не разделять 2007 г., ставить пробел, если его нет.
Сцеплять скобки со словами.
Заменять 1/2 1/4 3/4 на спецсимволы.
Следить за тем, чтобы предлоги и союзы не находились в конце строки.
Следить за тем, чтобы частицы бы, ли, же и т.д. не отрывались от предшествующего слова.
Форматировать русские денежные суммы, расставляя пробелы в нужных местах.
Заменять от 3-х до 5-и точек подряд на троеточие.
Притягивать к слову запятые, отделять пробелом от последующего слова.
Притягивать к слову восклицательный знак.
Делать замену для +-.
Обрабатывать вложенные кавычки.
Притягивание чисел к знаку умножения.
Запятые до «а» и «но».
Притягивание «;» к предшествующему слову.
Убирает лишние знаки: «??» в «?», «!!!!» в «!!!».
Правильные апострофы в «LO'Лайт».
Прямая речь.
Неразрывные IP-адреса.

I will also add that if there is a limit on the number of characters in the ad, then it is immediately better to limit the number of words (2 letters or more) that do not carry meaning (conjunctions, prepositions, etc.). Then the ad text will be much better for PEOPLE (and for search engines, of course)!
What is spamming in general (concepts: water content, nausea of ​​the text, etc.): here
Online text analysis: here
I.e. this should work immediately, before the announcement is accepted by the system (ie, usually before it is published).

P
posters, 2019-07-30
@posters

https://yandex.ru/dev/speller/
Have you watched?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question