For the purpose of this problem, we’ll consider any sequence of characters separated by a space to be a word (so a hyphenated word like "sister-in-law" should be considered one word, not three).Īdd to readability.c, below main, a function called count_words that takes one argument, a string of text, and that returns an int, the number of words in that text. The Coleman-Liau index cares not only about the number of letters but also about the number of words in a sentence. If you use it, be sure to include that header file atop your own code! Words Text: Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, "and what is the use of a book," thought Alice "without pictures or conversation?"ĭeclared in ctype.h is a function that you might find helpful, per. And remember, as you work through this program, that if you make use of any library functions, be sure to #include any corresponding header files. Specifically, implement in readability.c a main function that prompts the user with "Text: " using get_string and then prints that same text using printf. Let’s first write some C code that just gets some text input from the user, and prints it back out. If the index number is less than 1, your program should output "Before Grade 1". If the resulting index number is 16 or higher (equivalent to or greater than a senior undergraduate reading level), your program should output "Grade 16+" instead of giving the exact index number.Your program should print as output "Grade X" where X is the grade level computed by the Coleman-Liau formula, rounded to the nearest integer.You may assume that a letter is any lowercase character from a to z or any uppercase character from A to Z, any sequence of characters separated by spaces should count as a word, and that any occurrence of a period, exclamation point, or question mark indicates the end of a sentence. Your program should count the number of letters, words, and sentences in the text. Your program must prompt the user for a string of text using get_string.Implement your program in a file called readability.c in a directory called readability.If you were to take this paragraph, for instance, which has longer words and sentences than either of the prior two examples, the formula would give the text an twelfth-grade reading level.ĭesign and implement a program, readability, that computes the Coleman-Liau index of text. Text: As the average number of letters and words per sentence increases, the Coleman-Liau index gives the text a higher reading level. The Coleman-Liau index of a text is designed to output that (U.S.) grade level that is needed to understand some text. One such readability test is the Coleman-Liau index. Likewise, longer sentences probably correlate with higher reading levels, too.Ī number of “readability tests” have been developed over the years that define formulas for computing the reading level of a text. So what sorts of traits are characteristic of higher reading levels? Well, longer words probably correlate with higher reading levels. But an algorithm could likely figure that out too! Well, in many cases, a human expert might read a book and make a decision on the grade (i.e., year in school) for which they think the book is most appropriate. What does it mean, though, for a book to be at a particular reading level? White’s Charlotte’s Web is between a second- and fourth-grade reading level, and Lois Lowry’s The Giver is between an eighth- and twelfth-grade reading level. If not, retrace your steps and see if you can determine where you went wrong! BackgroundĪccording to Scholastic, E.B. Executing code readability.c should open the file where you will type your code for this problem set. Clubhouse Facebook GitHub Instagram LinkedIn ORCID Quora Reddit TikTok Telegram Twitterįor this problem, you’ll implement a program that calculates the approximate grade level needed to comprehend some text, per the below.Īnd see a file named readability.c. This is CS50 CS50’s Introduction to Computer Scienceĭavid J.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |