Solved

C++ program to perform to read non-punctuated text and give word frequency

Posted on 1998-04-14
9
215 Views
Last Modified: 2010-07-27
How to implement a C++ program to perform a case-insensitve, frequency of occurance, analysis of words contained within a non-punctuated text. Only blank spaces between words, newline characters, and a single $ to mark end of text.
Example text: Yellow Blue Green BLUE Red GREEN yellow $
Example output: Word:   Frequency:
                BLUE       2
                GREEN      2      CONVERT ALL WORDS TO
                RED        1        UPPERCASE
                YELLOW     2       in alphabetical order
0
Comment
Question by:Kevn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 

Author Comment

by:Kevn
ID: 1184294
Edited text of question
0
 

Author Comment

by:Kevn
ID: 1184295
It would be awesome to have the code by Thursday night.
What is the average time to expect a notification?
0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1184296
IS this a Homework assignment? If so, it would not be ethical for anyone here to do your work for you.

If it is homework, you could ask for pointers about how to write the code and then additional help in debugging it.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Kevn
ID: 1184297
Edited text of question
0
 

Author Comment

by:Kevn
ID: 1184298
I am in a C++ class but this is not an assignment. It is an exercise from the text on array's and pointers and it is giving me a hard time. The urgency is because I would like to fully comprehend the code before my test on Friday. I'll take all the help I can get!
0
 
LVL 84

Expert Comment

by:ozo
ID: 1184299
If you can post your code, and tell us where you're having difficulty,
we may be able to help explain it to you.

0
 
LVL 11

Accepted Solution

by:
alexo earned 200 total points
ID: 1184300
Use stream extraction (operator>>) to read words.  White space is considered as separators.  Stop when you reach '$'.  Convert strings to lowercase using tolower() loops, _strlwr() or any other supported function.
Use an STL map for frequency of occurance calculations.
0
 

Expert Comment

by:Ferd
ID: 1184301
I suggest you use a linked list to store words from the file.
As you read  in a new word store it in a temporary string variable.
Convert the string to uppercase, then add it to the link list.
Also when a new word is read traverse through the list to check if it already exists (check the list after the word is stored in the temporary string and converted to uppercase). If the word exists
do not add it to the linked list then increment the field in the linked list which stores the frequency of the word. If the word is not already in the linked list add it to it. Find out more about linked lists (or dynamic storage and structures) if you dont already know about it and you will now what I mean. I can send you the code if you really want but it may take longer.

0
 

Expert Comment

by:Ferd
ID: 1184302
A $ character is not required if the text is in a file (I am assuming the text is stored in a file). An end of file character (EOF) with ascii code(-1) is stored at the end of files.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ get user from AD  (VS6) 7 95
convert char array to number in c 5 91
Add values of each row in an array 3 70
VS2015 Redefinition errors 4 91
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question