MyNixOS website logo
Description

Syllable Counting and Readability Measurements.

An English language syllable counter, plus readability score measure-er. For readability, we support 'Flesch' Reading Ease and 'Flesch-Kincaid' Grade Level ('Kincaid' 'et al'. 1975) <https://stars.library.ucf.edu/cgi/viewcontent.cgi?article=1055&context=istlibrary>, Automated Readability Index ('Senter' and Smith 1967) <https://apps.dtic.mil/sti/citations/AD0667273>, Simple Measure of Gobbledygook (McLaughlin 1969), and 'Coleman-Liau' (Coleman and 'Liau' 1975) <doi:10.1037/h0076540>. The package has been carefully optimized and should be very efficient, both in terms of run time performance and memory consumption. The main methods are 'vectorized' by document, and scores for multiple documents are computed in parallel via 'OpenMP'.

sylcount

  • Version: 0.2-5
  • License:BSD 2-Clause
  • Project home: https://github.com/wrathematics/sylcount
  • Bug reports: https://github.com/wrathematics/sylcount/issues

A simple English language syllable counter, plus readability score measure-er. The package has been optimized to be very efficient, both in terms of run time performance and memory consumption. The main methods sylcount() and readability() are both vectorized by document. Scores for multiple documents are computed in parallel.

Installation

The stable version is available on CRAN:

install.packages("sylcount")

The development version is maintained on GitHub:

remotes::install_github("wrathematics/sylcount", subdir="R")

Example Usage

Let's start with some very simple data:

library(sylcount)
a = "I am the very model of a modern major general."
b = "I have information vegetable, animal, and mineral."

We can easily get the readability of one "document":

readability(a)
#   chars words nonwords sents sylls polys     re   gl      ari     smog
# 1    36    10        0     1    16     1 61.325 7.19 25.70125 8.841846

Both at once, scored one at a time:

readability(c(a, b))
#   chars words nonwords sents sylls polys        re       gl      ari      smog
# 1    36    10        0     1    16     1 61.325000  7.19000 25.70125  8.841846
# 2    41     7        0     1    17     4 -5.727143 15.79714 11.56941 14.554593

Both at once, scored as a single document:

readability(paste0(a, b, collapse=" "))
#   chars words nonwords sents sylls polys       re       gl     ari     smog
# 1    77    17        0     2    33     5 33.98397 10.63088 18.6353 12.16174

We can also just get the syllable counts if we want. The interface/behavior is similar to the above readability scoring function:

sylcount(a)
# [[1]]
#  [1] 1 1 1 2 2 1 1 2 2 3

sylcount(c(a, b))
# [[1]]
#  [1] 1 1 1 2 2 1 1 2 2 3
# 
# [[2]]
#  [1] 1 1 4 4 3 1 3

sylcount(paste(a, b, collapse=" "))
# [[1]]
#  [1] 1 1 1 2 2 1 1 2 2 3 1 1 4 4 3 1 3

sylcount(a, counts.only=FALSE)
# [[1]]
#       word syllables
# 1        I         1
# 2       am         1
# 3      the         1
# 4     very         2
# 5    model         2
# 6       of         1
# 7        a         1
# 8   modern         2
# 9    major         2
# 10 general         3

How It Works

The syllable counter first looks up each word in a hash table to see if its syllable count is known. If not, it uses a vowel counting rule to try to approximate it. The hash table uses a perfect hash function generated by gperf. For more information, see ?sylcount.

For a source for the readability measures, see ?readability.

For performance considerations, the maximum length allowed for a word is 64 characters. Anything longer will be treated as a "non-word". See the package documentation for readability() and sylcount() for more details.

Metadata

Version

0.2-6

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows