Locate and tag words in text file
<p>I need to read in a text file of 500 words or more(a real world article from newspaper, etc..) and locate and tag like this,  <code>&lt;location&gt; word &lt;location/&gt;</code>, and then print the entire article on the screen. Im using boost regex right now and its working ok. I want to try and use a list or array or some other data structure to have a list of the states and major cities, and search those and compare to the aticle. right now I'm using an array but I'm willing to use anything. Any ideas or clues?</p>

<pre><code>#include &lt;boost/regex.hpp&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;boost/iostreams/filter/regex.hpp&gt;
#include &lt;fstream&gt;


using namespace std;

int main()
{
string cities[389];
string states [60];
string filename, line,city,state;
ifstream file,cityfile, statefile;
int i=0;
int j=0;
cityfile.open("c:\\cities.txt");
while (!cityfile.eof())
{

    getline(cityfile,city);
        cities[i]=city; 
        i++;
    //for (int i=0;i&lt;500;i++)
        //file&gt;&gt;cities[i];
}
cityfile.close();

statefile.open("c:\\states.txt");
while (!statefile.eof())
{
    getline(statefile,state);
        states[j]=state; 
    //for (int i=0;i&lt;500;i++)
    //cout&lt;&lt;states[j];
    j++;
}
statefile.close();
//4cout&lt;&lt;cities[4];






cout&lt;&lt;"Please enter the path and file name "&lt;&lt;endl;
cin&gt;&gt;filename;
file.open(filename);

while (!file.eof())
{
        while(getline(file, line)
        {


        }




        while(getline(file, line))
        {


        //string text = "Hello world";
        boost::regex re("[A-Z/]\.[A-Z\]\.|[A-Z/].*[:space:][A-Z/]|C........a");
        //boost::regex re(
        string fmt = "&lt;locations&gt;$&amp;&lt;locations\&gt;";
        if(boost::regex_search(line, re))
            {
                 string result = boost::regex_replace(line, re, fmt);
                cout &lt;&lt; result &lt;&lt; endl;
            }
        /*else
            {
                cout &lt;&lt; "Found Nothing" &lt;&lt; endl;
            }*/

        }
}
file.close();

cin.get(),cin.get();
return 0;
</code></pre>

<p>}</p>
