![]() |
| ||
| Re: Determining the number of unique words in a .txt file change this: while (inFile.getline(line,Num))To this: while (inFile.getline(line,Num))Change wordSearch to this: bool wordSearch( char line[], int count, words array[])Eliminate wordSearchSetup() completely. count should be the number of unique words found. If it reaches 100 before completely reading the file you will have to output the full error message. If you want to keep track of the number of total words found in the file in addition to the number of unique words in the file, you can do that too. Once you have completed the file reading you can display array with each unique word and the number of times it was found. |
| ||
| Re: Determining the number of unique words in a .txt file Ok thanks, now I'm trying to determine the average occurence of each words, I'm starting out by finding out how many of each word there is, heres my function- void averageOccurrence(words array[], int array_length)It just gives me a large count like 150077, or 150079. |
| ||
| Re: Determining the number of unique words in a .txt file What's initial value of count member (must be zero)? |
| ||
| Re: Determining the number of unique words in a .txt file >>trying to determine the average occurence of each words You don't care what each word is to do this, you only need only need to know how many unique words there are----that would be count in my last post, and how many words there were in the file. The number of words in the file could be calculated as a running total as you read through the file, as indicated in my last post, or it can be calculated by looping through the array of unique words and adding up the number of each in a running total. For example. if there are three unique words with frequency of 3, 6 and 9 each respectively, then the average number of occurences of unique words would be 6. You can decide which approach you wish to take. However, the code you have posted in post #22 above doesn't have a chance of coming up with the correct answer. |
| ||
| Re: Determining the number of unique words in a .txt file Thanks a lot, that helps a lot. I'm on my last stat, I have to find the most commonly occuring word(s). Heres my function- void commonWord(double count[], int array_length, words array[])I dont get a compile-time error. But when I run the program, I get a message telling me the .exe file stopped working. |
| ||
| Re: Determining the number of unique words in a .txt file I'm now trying to write my stats to a text file, but its only writing two of the stats, and those stats come from the same function. Heres the code - #include <iostream> The "storeFile" function is the only one that prints to the file. BTW I know this code is unorganized and not the best way to do it, but this project is due tomorrow (12-10) |
| All times are GMT -4. The time now is 4:25 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC