User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 427,123 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,084 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1129 | Replies: 3
Reply
Join Date: Nov 2006
Location: Nicosia - Cyprus
Posts: 1
Reputation: georgioue is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
georgioue georgioue is offline Offline
Newbie Poster

C++ Assignment NEED HELP URGENTLY

  #1  
Nov 28th, 2006
Guys hello, i`m a new member here [IMG]http://images.devshed.com/fda/smilies/smile.gif[/IMG] Hello to everybody...I need urgently help... I have an assignment for C++.
"We have a collection of emails. This collection has emails from Linguist.org, these mails are legal. these are in a file called ling_filenames.txt. We also have a collection of spam emails in spam_filenames.txt. We have also a file called keywords.txt which has the key words to deside if an email is spam or ling. One word each line. Write a C++ program which checks the email collections and prints:
<messagecollection messages ="n">

<message file=" " category="spam" features="m">
<feature id="i1" freq="fi1"> k1 </feature>
<feature id="i2" freq="fi2"> k2 </feature>
...
<feature id="im" freq="fim"> km </feature>
</message>
...
<message file=" " category="legit| features="r">
<feature id="j1" freq="fj1"> q1 </feature>
<feature id="j2" freq="fj2"> q2 </feature>
...
<feature id="jr" freq="fjr"> qr </feature>
</message>
...
</messagecollection>

This is my code until now....PLEASE HELP ME!!!!!
  1. #include <iostream>
  2. #include <set>
  3. #include <fstream>
  4. #include <vector>
  5. #include <string>
  6. using namespace std;
  7.  
  8. string Keys_path="keywords.txt";
  9. string ling="ling_filenames.txt";
  10. string spam="spam_filenames.txt";
  11.  
  12. vector <string> words()
  13. {
  14. vector <string> Keys;
  15. string word;
  16. ifstream keysfile (Keys_path.c_str());
  17. while (keysfile>>word)
  18. Keys.push_back(word);
  19. return Keys;
  20. }
  21.  
  22. void Check (vector <string> keywords, string file, int c)
  23. {
  24. void CheckFile(vector <string> Kwords, string TFile);
  25. string word;
  26. int i;
  27. vector <string> AllFiles;
  28. ifstream files(file.c_str());
  29. while (files>>word)
  30. AllFiles.push_back(word);
  31. for (i=0; i<AllFiles.size(); i++) {
  32. CheckFile(keywords, AllFiles[i]);
  33. // cout<<
  34. }
  35. }
  36.  
  37. void CheckFile(vector <string> Kwords, string TFile)
  38. {
  39. set <string> txt;
  40. int i;
  41. string word, a;
  42. ifstream x (TFile.c_str());
  43. while (x>>word)
  44. txt.insert(word);
  45. for(i=0; i<Kwords.size(); i++)
  46. {
  47. a=Kwords[i];
  48. if(txt.find(a)!=txt.end()) {
  49. cout<<
  50. }
  51. }
  52. }
  53.  
  54. void CountLines (vector <string> Kwords, string TFile)
  55. {
  56. set <string> text;
  57. int i;
  58. int n=0;
  59. ifstream files(ling.c_str());
  60. while (files>>line) {
  61. AllFiles.push_back(line);
  62. }
  63. for(i=0; i<AllFiles.size(); i++)
  64. n++;
  65. ifstream files2(spam.c_str());
  66. while (files2>>line) {
  67. AllFiles2.push_back(line);
  68. }
  69. for(i=0; i<AllFiles2.size(); i++)
  70. n++;
  71. return n;
  72. }
  73.  
  74.  
  75. int main()
  76. {
  77. vector <string> Keywords=words();
  78. int c=0;
  79. int FeatureNumbers=0;
  80. Check(Keywords,ling,c);
  81. c++;
  82. Check(Keywords,spam,c);
  83. return 0;
  84. }
Last edited by WaltP : Nov 28th, 2006 at 6:51 am. Reason: Please use code tags -- see the post at the top of the forum about codes
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,197
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 38
Solved Threads: 932
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: C++ Assignment NEED HELP URGENTLY

  #2  
Nov 28th, 2006
>>PLEASE HELP ME!!!!!

help you do what? does your program compile ? (hint: no it does not).
what errors does your compiler produce?

if(txt.find(a)!=txt.end()) {  
cout<<
} 
Above is incomplete statement.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Reply With Quote  
Join Date: Mar 2008
Posts: 8
Reputation: Nimz is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Nimz's Avatar
Nimz Nimz is offline Offline
Newbie Poster

Re: C++ Assignment NEED HELP URGENTLY

  #3  
Apr 20th, 2008
i did try compiling it and it gave me error messages
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,197
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 38
Solved Threads: 932
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: C++ Assignment NEED HELP URGENTLY

  #4  
Apr 20th, 2008
What are some of the errors -- you'll have to post them because I can't see your computer's monitor from my chair.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 6:26 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC