•
•
•
•
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
![]() |
•
•
Join Date: Nov 2006
Location: Nicosia - Cyprus
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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!!!!!
"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!!!!!
cpp Syntax (Toggle Plain Text)
#include <iostream> #include <set> #include <fstream> #include <vector> #include <string> using namespace std; string Keys_path="keywords.txt"; string ling="ling_filenames.txt"; string spam="spam_filenames.txt"; vector <string> words() { vector <string> Keys; string word; ifstream keysfile (Keys_path.c_str()); while (keysfile>>word) Keys.push_back(word); return Keys; } void Check (vector <string> keywords, string file, int c) { void CheckFile(vector <string> Kwords, string TFile); string word; int i; vector <string> AllFiles; ifstream files(file.c_str()); while (files>>word) AllFiles.push_back(word); for (i=0; i<AllFiles.size(); i++) { CheckFile(keywords, AllFiles[i]); // cout<< } } void CheckFile(vector <string> Kwords, string TFile) { set <string> txt; int i; string word, a; ifstream x (TFile.c_str()); while (x>>word) txt.insert(word); for(i=0; i<Kwords.size(); i++) { a=Kwords[i]; if(txt.find(a)!=txt.end()) { cout<< } } } void CountLines (vector <string> Kwords, string TFile) { set <string> text; int i; int n=0; ifstream files(ling.c_str()); while (files>>line) { AllFiles.push_back(line); } for(i=0; i<AllFiles.size(); i++) n++; ifstream files2(spam.c_str()); while (files2>>line) { AllFiles2.push_back(line); } for(i=0; i<AllFiles2.size(); i++) n++; return n; } int main() { vector <string> Keywords=words(); int c=0; int FeatureNumbers=0; Check(Keywords,ling,c); c++; Check(Keywords,spam,c); return 0; }
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
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,197
Reputation:
Rep Power: 38
Solved Threads: 932
>>PLEASE HELP ME!!!!!
help you do what? does your program compile ? (hint: no it does not).
what errors does your compiler produce?
Above is incomplete statement.
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<<
} 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
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,197
Reputation:
Rep Power: 38
Solved Threads: 932
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
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Help needed with VB Assignment (Visual Basic 4 / 5 / 6)
- Many Errors while doing this assignment (C)
- Urgent! Change using class (C++)
- I need help on my 'address book' assignment! (C++)
Other Threads in the C++ Forum
- Previous Thread: convert char to hexadecimal
- Next Thread: default variable as a pointer in class



Linear Mode