Distinguish randomly generated texts from reasonable for human texts I have strings short texts of 2 types:
'23jd2032n0d2mn', 'fn830n30rn83', 'fhui29n4ok', 'qn4foml', ...
and
'sweetie23', 'king3prussia', 'maryjesus', 'lovedog4and_kitties', ...
Is there a way to distinguish one type from another?
I've tried to vectorize texts with word2vec and classify on these vectors with xgboost, but I didn't succeded to achieve got F1-score.
You could train a character-level language model, e.g. an LSTM, on the real short texts, and use the perplexity as the signal to know whether a piece of text is real or not.
In order to find an appropriate perplexity threshold, you can have a look at the distribution of perplexities over a validation holdout dataset.
UPDATE: There are multiple implementations of language models. For &quot;classical&quot; options, you can go for KenLM or if you have GPUs to train the model, you can use fairseq. Just remember to prepare your text to have character-level tokens (normally you just need to have a space between every letter).