Learn R Programming

quanteda (version 1.3.13)

textstat_readability: Calculate readability

Description

Calculate the readability of text(s) using one of a variety of computed indexes.

Usage

textstat_readability(x, measure = c("all", "ARI", "ARI.simple",
  "Bormuth", "Bormuth.GP", "Coleman", "Coleman.C2", "Coleman.Liau",
  "Coleman.Liau.grade", "Coleman.Liau.short", "Dale.Chall",
  "Dale.Chall.old", "Dale.Chall.PSK", "Danielson.Bryan",
  "Danielson.Bryan.2", "Dickes.Steiwer", "DRP", "ELF",
  "Farr.Jenkins.Paterson", "Flesch", "Flesch.PSK", "Flesch.Kincaid", "FOG",
  "FOG.PSK", "FOG.NRI", "FORCAST", "FORCAST.RGL", "Fucks", "Linsear.Write",
  "LIW", "nWS", "nWS.2", "nWS.3", "nWS.4", "RIX", "Scrabble", "SMOG",
  "SMOG.C", "SMOG.simple",      "SMOG.de", "Spache", "Spache.old",
  "Strain", "Traenkle.Bailer", "Traenkle.Bailer.2", "Wheeler.Smith",
  "meanSentenceLength", "meanWordSyllables"), remove_hyphens = TRUE,
  min_sentence_length = 1, max_sentence_length = 10000,
  intermediate = FALSE, ...)

Arguments

x

a character or corpus object containing the texts

measure

character vector defining the readability measure to calculate. Matches are case-insensitive.

remove_hyphens

if TRUE, treat constituent words in hyphenated as separate terms, for purposes of computing word lengths, e.g. "decision-making" as two terms of lengths 8 and 6 characters respectively, rather than as a single word of 15 characters

min_sentence_length, max_sentence_length

set the minimum and maximum sentence lengths (in tokens, excluding punctuation) to include in the computation of readability. This makes it easy to exclude "sentences" that may not really be sentences, such as section titles, table elements, and other cruft that might be in the texts following conversion.

For finer-grained control, consider filtering sentences prior first, including through pattern-matching, using corpus_trim.

intermediate

if TRUE, include intermediate quantities in the output

...

not used

Value

textstat_readability returns a data.frame of documents and their readability scores.

Examples

Run this code
# NOT RUN {
txt <- c(doc1 = "Readability zero one.  Ten, Eleven.", 
         doc2 = "The cat in a dilapidated tophat.")
textstat_readability(txt, "Flesch")
textstat_readability(txt, c("FOG", "FOG.PSK", "FOG.NRI"))

textstat_readability(data_corpus_inaugural[48:58], 
                     measure = c("Flesch.Kincaid", "Dale.Chall.old"))
# }

Run the code above in your browser using DataLab