Learn R Programming

koRpus (version 0.06-5)

readability.num: Calculate readability

Description

This function is a stripped down version of readability. It does not analyze text, but directly takes the values used by the formulae to calculate the readability measures.

Usage

readability.num(txt.features = list(sentences = NULL, words = NULL, letters = c(all = 0, l5 = 0, l6 = 0), syllables = c(all = 0, s1 = 0, s2 = 0), punct = NULL, all.chars = NULL, prepositions = NULL, conjunctions = NULL, pronouns = NULL, foreign = NULL, TTR = NULL, FOG.hard.words = NULL, Bormuth.NOL = NULL, Dale.Chall.NOL = NULL, Harris.Jacobson.NOL = NULL, Spache.NOL = NULL), index = c("ARI", "Bormuth", "Coleman", "Coleman.Liau", "Dale.Chall", "Danielson.Bryan", "Dickes.Steiwer", "DRP", "ELF", "Farr.Jenkins.Paterson", "Flesch", "Flesch.Kincaid", "FOG", "FORCAST", "Fucks", "Harris.Jacobson", "Linsear.Write", "LIX", "nWS", "RIX", "SMOG", "Spache", "Strain", "Traenkle.Bailer", "TRI", "Tuldava", "Wheeler.Smith"), parameters = list(), ...)

Arguments

txt.features
A named list with statistical information on the text, or an object of class kRp.readability (only its desc slot will then be used). Valid values are:
sentences:
The number of sentences.

words:
The number of words.

letters:
A named vector providing the number of letters. Must contain a value called "all", the total number of letters, and several values called "l", giving the number of words with letters. To calculate all implemented measures with default parameters, you need at least the values "l5" (words with five or less letters) and "l6" (words with six letters).

syllables:
Similar to letters, but providing the number of syllables. Must contain a value called "all", the total number of syllables, and several values called "s", giving the number of words with syllables. To calculate all implemented measures with default parameters, you need at least the values "s1" and "s2". Only needed to calculate measures which need syllable count (see readability).

punct:
The number of punctuation characters. Only needed to calculate "TRI".

all.chars:
The number of all characters (including spaces). Only needed to calculate Danielson.Bryan.

prepositions:
The number of prepositions. Only needed to calculate "Coleman" and "Traenkle.Bailer".

conjunctions:
The number of conjunctions. Only needed to calculate "Traenkle.Bailer".

pronouns:
The number of pronouns. Only needed to calculate "Coleman".

foreign:
The number of foreign words. Only needed to calculate "TRI".

TTR:
The type-token ratio. Only needed to calculate "Dickes.Steiwer".

FOG.hard.words:
The number of hard words, counted according to FOG. Only needed to calculate "FOG".

Bormuth.NOL:
Number of words not on the Bormuth word list. Only needed to calculate "Bormuth".

Dale.Chall.NOL:
Number of words not on the Dale-Chall word list. Only needed to calculate "Dale.Chall".

Harris.Jacobson.NOL:
Number of words not on the Harris-Jacobson word list. Only needed to calculate "Harris.Jacobson".

Spache.NOL:
Number of words not on the Spache word list. Only needed to calculate "Spache".

index
A character vector, indicating which indices should actually be computed.
parameters
A named list with magic numbers, defining the relevant parameters for each index. If none are given, the default values are used.
...
Additional options, see readability.

Examples

Run this code
## Not run: 
# test.features <- list(
#  sentences=18,
#  words=556,
#  letters=c(all=2918, l1=19, l2=92, l3=74, l4=80, l5=51, l6=49),
#  syllables=c(all=974, s1=316, s2=116),
#  punct=78,
#  all.chars=3553,
#  prepositions=74,
#  conjunctions=18,
#  pronouns=9,
#  foreign=0,
#  TTR=0.5269784,
#  Bormuth.NOL=192,
#  Dale.Chall.NOL=192,
#  Harris.Jacobson.NOL=240,
#  Spache.NOL=240)
# 
# # should not calculate FOG, because FOG.hard.words is missing:
# readability.num(test.features, index="all")
# ## End(Not run)

Run the code above in your browser using DataLab