Search code examples
c#textgraphreadability

How to get levels for Fry Graph readability formula?


I'm working in an application (C#) that applies some readability formulas to a text, like Gunning-Fog, Precise SMOG, Flesh-Kincaid.

Now, I need to implement the Fry-based Grade formula in my program, I understand the formula's logic, pretty much you take 3 100-words samples and calculate the average on sentences per 100-words and syllables per 100-words, and then, you use a graph to plot the values.

Here is a more detailed explanation on how this formula works.

I already have the averages, but I have no idea on how can I tell my program to "go check the graph and plot the values and give me a level." I don't have to show the graph to the user, I only have to show him the level.

I was thinking that maybe I can have all the values in memory, divided into levels, for example:

Level 1: values whose sentence average are between 10.0 and 25+, and whose syllables average are between 108 and 132.

Level 2: values whose sentence average are between 7.7 and 10.0, and .... so on

But the problem is that so far, the only place in which I have found the values that define a level, are in the graph itself, and they aren't too much accurate, so if I apply the approach commented above, trying to take the values from the graph, my level estimations would be too much imprecise, thus, the Fry-based Grade will not be accurate.

So, maybe any of you knows about some place where I can find exact values for the different levels of the Fry-based Grade, or maybe any of you can help me think in a way to workaround this.

Thanks


Solution

  • Well, I'm not sure about this being the most efficient solution, neither the best one, but at least it does the job.

    I gave up to the idea of having like a math formula to get the levels, maybe there is such a formula, but I couldn't find it.

    So I took the Fry's graph, with all the levels, and I painted each level of a different color, them I loaded the image on my program using:

    Bitmap image = new Bitmap(@"C:\FryGraph.png");
    
    image.GetPixel(int x, int y);

    As you can see, after loading the image I use the GetPixel method to get the color at the specified coordinates. I had to do some conversion, to get the equivalent pixels for a given value on the graph, since the scale of the graph is not the equivalent to the pixels of the image.

    In the end, I compare the color returned by GetPixel to see which was the Fry readability level of the text.

    I hope this may be of any help for someone who faces the same problem.

    Cheers.