Question

I have text files which are tagged using NER and I need to link them to a Google map.

<p>Gardai|NNP|O fear|VBP|O a|DT|O 28-year-old|JJ|O man|NN|O ,|,|O missing|VBG|O from|IN|O his|PRP$|O Dublin|NNP|I-PER home|NN|O for|IN|O a|DT|I-DAT week|NN|I-DAT

Although locations are not tagged correctly ie. Dublin is tagged as a person, I want to use the Google Geocoding API, to feed in the location which is identified as being NER tagged and find the location!

Is this possible?

I was thinking of creating a regex to extract any information which is tagged as a location, organisation or person and give it to Google and see if it has a latitude and longitude co-ordinatea that corresponds to it. Or take the 2-3 words in a row that are tagged as NER and add them as an entire address.

I'm just not sure about how I actually give this information to Google!?

Then I'm going to use the Json response to link the text file to the map using the address Google Geocoder matched.

Any insight or ideas would be greatly appreciated! Thanks

Was it helpful?

Solution

You can use JavaScript's Split function to get the data with delimiter being | and turn the data into an array. Let's say if your data is this html format:

<p id='data'>Gardai|NNP|O fear|VBP|O a|DT|O 28-year-old|JJ|O man|NN|O ,|,|O missing|VBG|O from|IN|O his|PRP$|O Dublin|NNP|I-PER home|NN|O for|IN|O a|DT|I-DAT week|NN|I-DAT</p>

To grab the data w/ delimiter set to | you can do the following with JavaScript:

function parseDataGeocode() {
    var mydata = document.getElementById('data').innerHTML;
    mydata = mydata.split('|');
    var locationIndexMod = 3; //this determines which element to pull from the array
    for (var i = 0; i < mydata.length; i++) {
        if (i % locationIndexMod == 0) {
            console.log(mydata[i]); //hopefully it's a location
            //do your marker creation after fetch Geocode Lat Lng
            //with mydata[i] as the location/address
        }
    }
}

window.onload = parseDataGeocode;

Here is the JSFiddle Demo. Using firebug on firefox or google chrome's console tool you can see the data output, and if you need help w/ creation of markers and Geocode please let me know.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top