content_ratio() computes the share of letters among the non-space
characters of each element of text. The share separates prose from other
units without relying on a language: sentences score close to one, while
reference lists, citations, tables of numbers, and identifiers, which consist
mostly of digits and punctuation and form spurious topics of their own when
they are clustered, score low.
It returns one value between 0 and 1 per element and is the measure behind
the min_content filters of clean_corpus(), segment(), and topics().
Value
A numeric vector of the same length as text, with values between
0 and 1; an empty or all-space element scores 0.
See also
clean_corpus() and segment(), which filter on it.
Examples
content_ratio(c("A real sentence here.", "OJ No L 297, 24.11.1979, p. 1."))
#> [1] 0.9444444 0.2500000
