使用 Google 地理编码 API 将命名实体识别标记的文件链接到 Google 地图

发布于 2024-10-24 19:26:53 字数 568 浏览 4 评论 0原文

我有使用 NER 标记的文本文件,我需要将它们链接到 Google 地图。

<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

尽管位置没有正确标记,即。都柏林被标记为一个人,我想使用 Google Geocoding API,输入被识别为 NER 标记的位置并找到该位置!

这可能吗?

我正在考虑创建一个正则表达式来提取标记为位置、组织或个人的任何信息,并将其提供给 Google,看看它是否具有与其相对应的纬度和经度坐标。或者取出一行中标记为 NER 的 2-3 个单词,并将它们添加为整个地址。

我只是不确定如何将这些信息提供给 Google!?

然后,我将使用 Json 响应,使用 Google Geocoder 匹配的地址将文本文件链接到地图。

任何见解或想法将不胜感激! 谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缪败 2024-10-31 19:26:53

您可以使用 JavaScript 的 Split 函数 来获取分隔符为 | 并将数据转换为数组。假设您的数据是这种 html 格式:

<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>

要获取分隔符设置为 | 的数据,您可以使用 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;

这是 JSFiddle 演示。使用 firefox 上的 firebug 或 google chrome 的控制台工具,您可以看到数据输出,如果您需要创建标记和地理编码的帮助,请告诉我。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文