protected void CalculateReability(object sender, EventArgs e)
        {
            string  text    = HttpUtility.HtmlEncode(txtInput.Text);
            Metrics metrics = MetricsCalculator.Calculate(text);

            txtSentencesWords.Text   = metrics.SentenceCount + ", " + metrics.WordCount;
            txtWordsPerSentence.Text = String.Format("{0:0.00}", metrics.WordsPerSentence);

            txtPercentProperModifiers.Text =
                String.Format("{0:0.00}  max expectable ({1:0.00}), ", metrics.ProperModiferPercent
                              , metrics.ProperModifierMaximum);

            txtComplexNps.Text =
                String.Format("{0:0.00}  max expectable ({1:0.00})", metrics.ComplexNounPhrasePercent,
                              metrics.ComplexNoundPhraseMaximum);

            txtPercentFunctionWords.Text =
                String.Format("{0:0.00}  max expectable ({1:0.00})", metrics.FunctionWordPercent, metrics.FunctionWordMaximum);

            txtCoordinatingWords.Text =
                String.Format("{0:0.00}  max expectable ({1:0.00})", metrics.CoordinatingPercent, metrics.CoordinatingMaximum);
        }
        private int ProcessDirectory(DirectoryInfo directoryInfo, int fileCount, ref int rowCount, StringBuilder sb, int theCount)
        {
            if (directoryInfo.FullName.Contains("_svn") || directoryInfo.FullName.Contains(".svn"))
            {
                return(fileCount);
            }
            //string query = search.Text;

            DirectoryInfo[] subDirectories = directoryInfo.GetDirectories();
            foreach (DirectoryInfo subDirectory in subDirectories)
            {
                //Recursion going on here...
                fileCount += ProcessDirectory(subDirectory, fileCount, ref rowCount, sb, theCount);
            }

            FileInfo[] fileInfos = directoryInfo.GetFiles();
            foreach (FileInfo file in fileInfos)
            {
                if ((file.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                {
                    continue;
                }
                if (file.FullName.Contains("_svn") || file.FullName.Contains(".svn"))
                {
                    continue;
                }

                fileCount++;
                using (StreamReader reader = file.OpenText())
                {
                    string row = reader.ReadToEnd();

                    if (row == null)
                    {
                        continue;
                    }

                    sb.Append("<tr><td>");
                    sb.Append("<a href=\"DisplayText.aspx?file=");
                    string[] splitOn = new[] { "corpus" };
                    sb.Append(file.FullName.Split(splitOn, StringSplitOptions.RemoveEmptyEntries)[1]);
                    sb.Append("\">");
                    sb.Append(CorpusUtils.ExtractTitle(file.Name));
                    sb.Append("</a></td><td>");
                    sb.Append(CorpusUtils.ExtractAuthor(file.DirectoryName));
                    sb.Append("</td>");

                    //metrics

                    Metrics metrics = MetricsCalculator.Calculate(row);
                    sb.Append("<td>");
                    sb.Append(string.Format("{0:0.0}", metrics.ComplexNounPhrasePercent));
                    sb.Append("</td><td>");
                    sb.Append(string.Format("{0:0.0}", metrics.CoordinatingPercent));
                    sb.Append("</td><td>");
                    sb.Append(string.Format("{0:0.0}", metrics.FunctionWordPercent));
                    sb.Append("</td><td>");
                    sb.Append(string.Format("{0:0.0}", metrics.ProperModiferPercent));
                    sb.Append("</td><td>");
                    sb.Append(string.Format("{0:0.0}", metrics.WordsPerSentence));
                    sb.Append("</td><td>");

                    double composite =
                        (metrics.WordsPerSentence / 9.5
                         +
                         metrics.ProperModiferPercent / .5
                         +
                         metrics.FunctionWordPercent / 2.5
                         +
                         metrics.CoordinatingPercent / 0.3
                         +
                         metrics.ComplexNounPhrasePercent / 0.3) / 5;

                    sb.Append(string.Format("{0:0.0}", composite));
                    sb.Append("</td>");
                    sb.Append("</tr>");
                }
            }

            return(fileCount);
        }