Answer the question
In order to leave comments, you need to log in
Arrangement of missing spaces in the text. How to do it right?
All the best!
Answered the question Is there a solution, what would the users write like that? and decided to continue the development of the topic.
If by accident (or intentionally) the words are "glued": written without a space .
How can they be correctly separated (with "the least bloodshed")?
In advance, thank you all for your help!
Answer the question
In order to leave comments, you need to log in
In short, no way. Google and Yandex clearly have algorithms and libraries with such functionality, but I did not find anything similar in the public domain separately. If the problem is a purely "visual" property (lines do not fit into certain blocks or break the layout), then there is 2 way out:
- Change the behavior of blocks with text through css overflow-wrap: break-word;
,
- or programmatically break words longer than a certain number of characters into blocks of N characters (and it is more logical to do this is when outputting, not when processing incoming data).
UPD: As an option - isolate long words and pull the api of Google or Yandex to check for "lice".
There are dictionaries, you download them and use them. You break the word into coincidences. Yes, you have to do it manually, but it's just too much. In order for everything to be fast, the dictionary must be translated into a structure convenient for work.
For example, " written without a space", going through the dictionary you will find a match written , there are no words in s , you add it to the first match, then going through it again, you will find the word without , then you will find a space , there will be an ending, you attach it. The result will be " written without spaces ".
as an option for a head-on solution, make an array of all words (including all declensions and conjugations), replay all words in the text into words with spaces (you can on both sides), then simply remove extra spaces using regex. For example.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question