2

私は、Gunning-Fog、Precise SMOG、Flesh-Kincaidなど、いくつかの読みやすさの式をテキストに適用するアプリケーション(C#)で作業しています。

ここで、プログラムにFryベースのGrade式を実装する必要があります。式のロジックを理解しています。ほとんどの場合、100語のサンプルを3つ取り、100語あたりの文と100語あたりの音節の平均を計算します。 、グラフを使用して値をプロットします。

この式がどのように機能するかについてのより詳細な説明があります。

私はすでに平均を持っていますが、「グラフをチェックして値をプロットし、レベルを教えてください」とプログラムに指示する方法がわかりません。グラフをユーザーに表示する必要はありません。レベルを表示するだけです。

たとえば、次のように、レベルに分割されたすべての値をメモリに含めることができると考えていました。

レベル1:文の平均が10.0〜25 +で、音節の平均が108〜132の値。

レベル2:文の平均が7.7から10.0の間の値、および....など

しかし、問題は、これまでのところ、レベルを定義する値を見つけた唯一の場所がグラフ自体にあり、それらはあまり正確ではないため、上記のアプローチを適用すると、グラフからの値では、私のレベルの推定値は不正確すぎるため、フライベースのグレードは正確ではありません。

ですから、フライベースのグレードのさまざまなレベルの正確な値を見つけることができる場所について知っている人もいれば、これを回避する方法で考えるのを手伝ってくれる人もいるかもしれません。

ありがとう

4

3 に答える 3

1

まあ、これが最も効率的な解決策であり、最良の解決策でもないかどうかはわかりませんが、少なくともそれは仕事をします。

レベルを取得するための数式のようなものを持っているという考えをあきらめました、多分そのような数式があるかもしれません、しかし私はそれを見つけることができませんでした。

そこで、すべてのレベルを含むFryのグラフを取得し、各レベルを異なる色でペイントしました。これらを使用して、プログラムに画像をロードしました。

Bitmap image = new Bitmap(@"C:\FryGraph.png");

image.GetPixel(int x, int y);

ご覧のとおり、画像を読み込んだ後、GetPixelメソッドを使用して、指定した座標の色を取得します。グラフのスケールは画像のピクセルと同等ではないため、グラフ上の特定の値と同等のピクセルを取得するには、変換を行う必要がありました。

最後に、GetPixelによって返された色を比較して、テキストのFryの読みやすさのレベルを確認します。

これが同じ問題に直面している人の助けになることを願っています。

乾杯。

于 2010-03-17T00:16:44.223 に答える
0

グラフの式を決定するだけです。つまり、文の数と音節の数を受け入れ、レベルを返す式です。

数式が見つからない場合は、自分で判断できます。グラフ上の各線の線形方程式を推定します。また、「長い単語」と「長い文」の領域の「範囲外」の領域を推定します。

ここで、各ポイントについて、それが存在する領域を決定するだけです。上にある行と下にある行。これはかなり単純な代数ですが、残念ながら、これはその方法を説明するために私が見つけることができる最良のリンクです。

于 2010-03-17T00:34:13.063 に答える
0

私はこれを解決するための最初のパスを作成しました。これは、将来誰かが探している場合に備えて共有すると思いました。上記の答えに基づいて、おおよそのグレードレベルを決定するために使用できる線形方程式の一般的なリストを作成しました。最初に値を修正して、より線形にする必要がありました。これは無効な領域を考慮していませんが、私はそれを再検討するかもしれません。方程式のクラス:

public class GradeLineEquation
{
    // using form y = mx+b
    // or y=Slope(x)=yIntercept

    public int GradeLevel { get; set; }

    public float Slope { get; set; }
    public float yIntercept { get; set; }

    public float GetYGivenX(float x)
    {
        float result = 0;
        result = (Slope * x) + yIntercept;
        return result;
    }

    public GradeLineEquation(int gradelevel,float slope,float yintercept)
    {
        this.GradeLevel = gradelevel;
        this.Slope = slope;
        this.yIntercept = yintercept;
    }


}

FryCalculatorは次のとおりです。

public class FryCalculator
{

    //this class normalizes the plot on the Fry readability graph the same way a person would, by choosing points on the graph based on values even though
    //the y-axis is non-linear and neither axis starts at 0.  Just picking a relative point on each axis to plot the intercept of the zero and infinite scope lines

    private List<GradeLineEquation> linedefs = new List<GradeLineEquation>();

    public FryCalculator()
    {
        LoadLevelEquations();
    }
    private void LoadLevelEquations()
    {
        // load the estimated linear equations for each line with the 
        // grade level, Slope, and y-intercept
        linedefs.Add(new NLPTest.GradeLineEquation(1, (float)0.5, (float)22.5));
        linedefs.Add(new NLPTest.GradeLineEquation(2, (float)0.5, (float)20.5));
        linedefs.Add(new NLPTest.GradeLineEquation(3, (float)0.6, (float)17.4));
        linedefs.Add(new NLPTest.GradeLineEquation(4, (float)0.6, (float)15.4));
        linedefs.Add(new NLPTest.GradeLineEquation(5, (float)0.625, (float)13.125));
        linedefs.Add(new NLPTest.GradeLineEquation(6, (float)0.833, (float)7.333));
        linedefs.Add(new NLPTest.GradeLineEquation(7, (float)1.05, (float)-1.15));
        linedefs.Add(new NLPTest.GradeLineEquation(8, (float)1.25, (float)-8.75));
        linedefs.Add(new NLPTest.GradeLineEquation(9, (float)1.75, (float)-24.25));
        linedefs.Add(new NLPTest.GradeLineEquation(10, (float)2, (float)-35));
        linedefs.Add(new NLPTest.GradeLineEquation(11, (float)2, (float)-40));
        linedefs.Add(new NLPTest.GradeLineEquation(12, (float)2.5, (float)-58.5));
        linedefs.Add(new NLPTest.GradeLineEquation(13, (float)3.5, (float)-93));
        linedefs.Add(new NLPTest.GradeLineEquation(14, (float)5.5, (float)-163));
    }


    public int GetGradeLevel(float avgSylls,float avgSentences)
    {
        // first normalize the values given to cartesion positions on the graph
        float x = NormalizeX(avgSylls);
        float y = NormalizeY(avgSentences);

        // given x find the first grade level equation that produces a lower y at that x
        return linedefs.Find(a => a.GetYGivenX(x) < y).GradeLevel;
    }

    private float NormalizeY(float avgSentenceCount)
    {
        float result = 0;
        int lower = -1;
        int upper = -1;
        // load the list of y axis line intervalse
        List<double> intervals = new List<double> {2.0, 2.5, 3.0, 3.3, 3.5, 3.6, 3.7, 3.8, 4.0, 4.2, 4.3, 4.5, 4.8, 5.0, 5.2, 5.6, 5.9, 6.3, 6.7, 7.1, 7.7, 8.3, 9.1, 10.0, 11.1, 12.5, 14.3, 16.7, 20.0, 25.0 };
        // find the first line lower or equal to the number we have
        lower = intervals.FindLastIndex(a => ((double)avgSentenceCount) >= a);

        // if we are not over the top or on the line grab the next higher line value
        if(lower > -1 && lower < intervals.Count-1 && ((float) intervals[lower] != avgSentenceCount))
            upper = lower + 1;

        // set the integer portion of the respons
        result = (float)lower;
        // if we have an upper limit calculate the percentage above the lower line (to two decimal places) and add it to the result
        if(upper != -1)
             result += (float)Math.Round((((avgSentenceCount - intervals[lower])/(intervals[upper] - intervals[lower]))),2); 

        return result;
    }

    private float NormalizeX(float avgSyllableCount)
    {
        // the x axis is MUCH simpler.   Subtract 108 and divide by 2 to get the x position relative to a 0 origin.
        float result = (avgSyllableCount - 108) / 2;
        return result;
    }

}
于 2018-04-10T13:42:12.000 に答える