I am working on a program to help make a small "dictionary" for our robot project ( see Practice Speaking English for more detail ).
The purpose for this small program is read in a word and its meaning which are provided in word.txt and meaning.txt. Then the program will convert it to the requested form for our robot.
Now with Daved's help (THX very much!), I make the program work for one single word:
The input are:Code:#include <iostream> #include <fstream> using namespace std; int main() { ifstream input; char word[80]; char meaning[200]; input.open("word.txt"); if (input.fail()) { cout<<"File doesn't exist."<<endl; system("pause"); return 0; } ofstream output; output.open("output.txt"); input>>word; cout<<word<<endl; output<<word<<endl; input.clear(); input.close(); input.open("meaning.txt"); while (input.getline(meaning, 200, '.')) { cout<<meaning<<endl; output<<meaning<<endl; cout<<"Copying....."<<endl; input.close(); //Your main question is here output<<"<category>"<<endl; output<<"<pattern> WHAT IS THE MEANING OF "<<word<<" </pattern>"<<endl; output<<"<template><random>"<<endl; output<<"<li> Its meaning is "<<meaning<<".</li>"<<endl; output<<"<li> It means "<<meaning<<".</li>"<<endl; output<<"<li> It is "<<meaning<<".</li>"<<endl; output<<"</random></template>"<<endl; output<<"</category>"<<endl; //This is alternative question #1 output<<"<category>"<<endl; output<<"<pattern> WHAT DOES "<<word<<" MEAN </pattern>"<<endl; output<<"<template><srai> WHAT IS THE MEANING OF "<<word<<" </srai></template>"<<endl; output<<"</category>"<<endl; //This is alternative question #2 output<<"<category>"<<endl; output<<"<pattern> WHAT DOES "<<word<<" STAND FOR </pattern>"<<endl; output<<"<template><srai> WHAT IS THE MEANING OF "<<word<<" </srai></template>"<<endl; output<<"</category>"<<endl; //This is alternative question #3 output<<"<category>"<<endl; output<<"<pattern> CAN YOU TELL ME WHAT "<<word<<" IS </pattern>"<<endl; output<<"<template><srai> WHAT IS THE MEANING OF "<<word<<" </srai></template>"<<endl; output<<"</category>"<<endl; //This is alternative question #4 output<<"<category>"<<endl; output<<"<pattern> COULD YOU TELL ME WHAT "<<word<<" IS </pattern>"<<endl; output<<"<template><srai> WHAT IS THE MEANING OF "<<word<<" </srai></template>"<<endl; output<<"</category>"<<endl; //This is alternative question #5 output<<"<category>"<<endl; output<<"<pattern> CAN YOU TELL ME WHAT "<<word<<" MEANS </pattern>"<<endl; output<<"<template><srai> WHAT IS THE MEANING OF "<<word<<" </srai></template>"<<endl; output<<"</category>"<<endl; //This is alternative question #6 output<<"<category>"<<endl; output<<"<pattern> COULD YOU TELL ME WHAT "<<word<<" MEANS </pattern>"<<endl; output<<"<template><srai> WHAT IS THE MEANING OF "<<word<<" </srai></template>"<<endl; output<<"</category>"<<endl; //This is alternative question #7 output<<"<category>"<<endl; output<<"<pattern> DO YOU KNOW "<<word<<" </pattern>"<<endl; output<<"<template><srai> WHAT IS THE MEANING OF "<<word<<" </srai></template>"<<endl; output<<"</category>"<<endl; //This is alternative question #8 output<<"<category>"<<endl; output<<"<pattern> DO YOU KNOW WHAT "<<word<<" IS </pattern>"<<endl; output<<"<template><srai> WHAT IS THE MEANING OF "<<word<<" </srai></template>"<<endl; output<<"</category>"<<endl; //This is alternative question #9 output<<"<category>"<<endl; output<<"<pattern> DO YOU KNOW WHAT "<<word<<" MEANS </pattern>"<<endl; output<<"<template><srai> WHAT IS THE MEANING OF "<<word<<" </srai></template>"<<endl; output<<"</category>"<<endl; } cout<<"done!"<<endl; system("pause"); return 0; }
In word.txt:
In meaning.txt:PCC
The output is:Pasadena City College, the best college in LA.
Just as what I expexted. But Now I want to make it work for a list of words: meaning, I put 100 words in word.txt then 100 corresponding meanings in meaning.txt, and output the answers.PCC
Pasadena City College, the best college in LA
<category>
<pattern> WHAT IS THE MEANING OF PCC </pattern>
<template><random>
<li> Its meaning is Pasadena City College, the best college in LA.</li>
<li> It means Pasadena City College, the best college in LA.</li>
<li> It is Pasadena City College, the best college in LA.</li>
</random></template>
</category>
<category>
<pattern> WHAT DOES PCC MEAN </pattern>
<template><srai> WHAT IS THE MEANING OF PCC </srai></template>
</category>
<category>
<pattern> WHAT DOES PCC STAND FOR </pattern>
<template><srai> WHAT IS THE MEANING OF PCC </srai></template>
</category>
<category>
<pattern> CAN YOU TELL ME WHAT PCC IS </pattern>
<template><srai> WHAT IS THE MEANING OF PCC </srai></template>
</category>
<category>
<pattern> COULD YOU TELL ME WHAT PCC IS </pattern>
<template><srai> WHAT IS THE MEANING OF PCC </srai></template>
</category>
<category>
<pattern> CAN YOU TELL ME WHAT PCC MEANS </pattern>
<template><srai> WHAT IS THE MEANING OF PCC </srai></template>
</category>
<category>
<pattern> COULD YOU TELL ME WHAT PCC MEANS </pattern>
<template><srai> WHAT IS THE MEANING OF PCC </srai></template>
</category>
<category>
<pattern> DO YOU KNOW PCC </pattern>
<template><srai> WHAT IS THE MEANING OF PCC </srai></template>
</category>
<category>
<pattern> DO YOU KNOW WHAT PCC IS </pattern>
<template><srai> WHAT IS THE MEANING OF PCC </srai></template>
</category>
<category>
<pattern> DO YOU KNOW WHAT PCC MEANS </pattern>
<template><srai> WHAT IS THE MEANING OF PCC </srai></template>
</category>
Do you think I should use array to do the input of the words?