Search code examples
algorithmmathpseudocodenotation

How to read dale-chall mathematical notation?


How do I calculate this dale-chall mathematical notation? or how is it converted to easier pseudo code?

I am trying to understand this concept to implement a text readability analyzer.

Is it like the following? altough ... how is what comes after 0.1579 and 0.0496 calculated?

0.1579 ( (difficult words - words) * 100 ) + 0.0496 (words - sentences)

Solution

  • The given formula will be written as follows in the most common programming languages:

    (0.1579 * ((difficultWords / words) * 100)) + (0.0496 * (words / sentences))
    

    The above expression will work in Python, Ruby, Javascript, Java, C, C++, C#, etc. Notice that we use * for multiplication (you can't omit the operator) and / for division, and we add as many parentheses as needed to eliminate any ambiguities in evaluation order.

    When you're actually implementing the above code you'll have to be careful with divisions - some languages (for example: Java, Python 2.x) will truncate decimals if both operands are integer values. To get around this problem you can either declare the variables difficultWords, words and sentences using a data type that allows for decimals (say, double) or you can explicitly convert the variables to a decimal data type at the time of performing the division. For example, the formula will look like this in Java:

    (0.1579 * (((double) difficultWords / words) * 100)) + (0.0496 * ((double) words / sentences))