Description
Using this code, without any other change, provide the missing code for function "printConcordance".
It should:
[login to view URL] your name followed by “CONCORDANCE” on one line
[login to view URL] through keys in order
[login to view URL] through words in order
[login to view URL] you find the key, print the following on one line:
1.<= 3 preceding words (with spaces between)
[login to view URL] “ >> “, key, “ << ”
3.<=3 following words (with spaces between)
Code
/* implement KWIC w/o data structures other than string & array - accept restrictions */
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
#define MAXWORDS 100
string myFile = "[login to view URL]";
string words [MAXWORDS]; // severe limitation!!
int nWords=0;
int readWords(const char* fileName, int maxWords, string words[]) {
int nWords=0;
ifstream inpt;
[login to view URL] (fileName, std::ifstream::in);
if (!inpt.is_open()) {
cout << " ! failed to open " << myFile << endl;
exit(1);
}
string word;
while ( inpt>> word && nWords<maxWords) {
words[nWords++] = word;
cout << "input: " << word << endl;
}
[login to view URL]();
return nWords;
}
bool findKey(const string target, const int nWrds, const string wrds[]) {
//cout << "search for " << target << endl;
for (int i=0; i<nWrds; i++) {
//cout << " compare " << target << "to " << wrds[i] << endl;
if ([login to view URL](wrds[i])==0) return true;
}
return false;
}
// inserts word in lexicographic order into wrds and returns number of words
int insertSortedKey(string newWrd, const int nWrds, string wrds []) {
//cout << "inserting: " << newWrd ;
int insertionPoint =0;
while (insertionPoint<nWrds ) {
if ([login to view URL](wrds[insertionPoint])<0) break;
insertionPoint++;
}
int j = nWrds;
while (j>insertionPoint) {
wrds[j]=wrds[j-1];
j--;
}
//cout << " at " << insertionPoint << endl;
wrds[insertionPoint]= newWrd;
return nWrds+1;
}
int getSortedKeys(const int nWrds, string wrds[], string keys[]) {
int nKeys=0;
for (int i = 0; i<nWords; i++) {
if (!findKey(wrds[i],nKeys,keys)) {
nKeys = insertSortedKey(wrds[i], nKeys, keys);
}
}
return nKeys;
}
void printConcordance(const int nKeys, const string keys[], const int nWords, const string words[]) {
/ / deleted
}
int main () {
// read words
nWords = readWords(&myFile[0], MAXWORDS, words);
// for (int i =0; i<nWords; i++)
// cout << words[i] << endl;
string keys[MAXWORDS];
int nKeys = getSortedKeys(nWords, words, keys);
// for (int i =0; i<nKeys; i++)
// cout << "key: " << keys[i] << endl;
printConcordance(nKeys, keys, nWords, words);
return 0;
}
hi this is Asad, i have a lot of experience in c++ programming, this is very simple task for me,hire me wont disappoint you cheers :)
p.s price in negotiable
Hello Hiring Manager!
i have done graduation in computer science.
i have an experience of 4+ years in web designing and web development and have been doing job in software house since last 4 years.
i am an expert in php, c++,jquer, ajax, htm, css and psd to html conversion. i am also master template designer and had recently designed 5 master templates each having 30 themes
kindly visit my profile and see i have done 3 jobs in c++ and send them on time so that students dont get late.
i will complete your job in few hours .so send me message and award me.i am ready to start it now.
thanks
i have worked on various langaues like c, c++ with windows api and opengl, java, xhtml/html, sql, php 4/5, java script, objective c, css/css3, action script etc............…