Phillip Trelford's Array

POKE 36879,255

Fog Index

The Gunning Fog Index is an estimate of readability based on:

  • the number words per sentences
  • the number of complex words

The index estimates the years of formal education needed to understand the text on a first reading. Texts for a wide audience generally need a fog index less than 12.

If you have Silverlight 4 installed you, paste your text below to get a score:


The Gunning Fog Index formula along with some samples can be found on Wikipedia. The paste window gives results that are quite close to the values given in the samples, but this is an approximation.

The paste box was written in F# using the freely available Visual Studio 2010 Shell. If you are interested in the implementation some code snippets follow.

Compute approximate fog index:

let toFogIndex text =
    let sentences = getSentences text
    let words = sentences |> Array.collect getWords
    let complexWords =
        words
        |> Array.filter (fun word -> word.Length>3)
        |> Array.map removeSuffixes            
        |> Array.filter (fun word -> countSyllables word >= 3)
    0.4 * ((float words.Length/float sentences.Length) + 
           (100.0 * float complexWords.Length/float words.Length))

 

React to text pasted into window; computing new Fog index in the background then updating the display on the UI thread:

do  pasteText.TextChanged         
    |> Observable.map (fun _ -> pasteText.Text)
    |> Observable.onThreadPool
    |> Observable.map toFogIndex
    |> Observable.onDispatcher
    |> Observable.subscribe (fun index -> 
        label.Text <- sprintf "Fog Index %0.2f" index
    )
    |> remember

 

References:

FogIndexSource.zip (5.71 kb)

Comments are closed