Thread: Text Analyser Application

  1. #1
    Registered User
    Join Date
    Nov 2015
    Posts
    3

    Text Analyser Application

    We have been asked to develop a word analyzing application in C.

    Here is the problem placed down:

    1. Character analyser module, which provides functions to establish: - Number of characters in the text (including letters, digits, spaces, symbols, etc.). - Number of letters in the text. - Number of digits in the text. - Number of other characters (symbols etc.) - Frequency distribution of all letters (the amount of relative occurrence of each letter in the text as percentage (as a figure between 0.0%-100.0%), i.e. 5.34% of all characters might be an ‘a’, 1.2% might be a ‘b’ etc.). - Frequency distribution of all digits (i.e. the amount of relative occurrence of each digit in the text as percentage,). - Summary report, which returns a string containing the number of characters, letters, digits and other characters. - None of these functions should interact directly with the user – all input from user and output to user should be performed in the application module (see below).

    2. Word analyser module, which provides functions to establish: - Number of words in the text (see definition of “word” below). - A list of all unique words occurring in the text (each word is stored only once and words are kept in order of appearance). Ensure your module can handle at least 200 unique words. - Number of unique words (i.e. how many different words appear in the file – this is not case sensitive and the words “card” and “Card” are counted as the same word). - Number of occurrences of a specific word. - Summary report, which returns a string containing the number of words in the file and the number of unique words number of characters, letters, digits, whitespaces and symbols. - None of these functions should interact directly with the user.

    3. Application module, which performs all input/output interactions with the user a) Prompt the user to choose either character analyser or word analyser b) Prompt the user for the filename c) Obtains the summary report from the analyser and displays the report to the screen. d) Offer to get result from any analyser module function (depending on type of analyser, e.g. if word analyser is chosen, then user can pick either “number of words in text”, “number of unique words”, “list of unique words”, “Number of occurrence of specific word ‘xxx’ ”, “summary report” or “leave menu”). If “leave menu” is chosen, offer “Choose new analyser” (goes back to step a), “Choose new file” (goes back to step b) or “Exit application”.

    So far we have finished up with part 1 and are feeling ok on part 3, but we are stumped on part 2.

    Any help I could get on part 2 would be great!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    There are a number of possible data structures that could be used, but the requirements that "words are kept in order of appearance" and "handle at least 200 unique words" suggest an array, perhaps an array of struct objects:
    Code:
    struct WordCount
    {
        char word[WORD_SIZE];
        size_t count;
    };
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need to edit text from within my application.
    By spiroth10 in forum C++ Programming
    Replies: 2
    Last Post: 12-15-2006, 03:15 PM
  2. Refreshing a Text file in GUI application?
    By solomonHk in forum C Programming
    Replies: 2
    Last Post: 01-04-2005, 03:02 PM
  3. Getting the text from another application
    By chrischar in forum Windows Programming
    Replies: 5
    Last Post: 08-10-2003, 05:57 AM
  4. rich text in application
    By juschillin in forum Windows Programming
    Replies: 1
    Last Post: 09-11-2002, 09:26 AM
  5. F1 track analyser
    By Unregistered in forum Game Programming
    Replies: 1
    Last Post: 01-22-2002, 09:48 AM