---
url: 'http://workflows-of-ai.com/blog/find-real-locations-text'
title: 'Find real locations from text'
author:
  name: 'Marcus Johansson'
  url: 'http://workflows-of-ai.com/about/marcus-johansson'
date: '2024-02-02T12:02:30+01:00'
updated: '2026-10-10T12:14:04+02:00'
type: article
summary: 'Find real places in free text with AI Interpolator OpenAI, verify them with the Google Places API and plot them with Address and Geolocation.'
tags:
  - 'Marcus Johansson'
  - Workflows
  - 'Drupal AI'
image: 'http://workflows-of-ai.com/sites/default/files/previews/1f14ba76e13049b3.jpg'
published: true
og:
  site_name: 'Workflows of AI'
  'image:width': '1280'
  'image:height': '720'
  'image:alt': 'Find real locations from text'
---
Drupal AI

# Find real locations from text

Turn the places named in an article into verified addresses on a Google Map, without anyone copying them from Google Maps by hand.

  Marcus Johansson

February 2, 2024 · 1 min read

 ## About this video

This workflow is using the Address field and the Geolocation module to show addresses on a Google Maps map for an article.

We will then take a raw mass of text with possible locations, have the AI Interpolator OpenAI figure them out, and then search the Google Places API to verify that they actually exist and populate the address field.

This can be used with any creative prompt towards OpenAI.

*This video is from before the AI Interpolator module became AI Automators, part of the [AI module](https://www.drupal.org/project/ai). Module and menu names have changed since, and some steps look different today.*

## Watch the video

[Watch on YouTube: Find real locations from text](https://www.youtube.com/watch?v=irHTd8IV6Jk)

### Video chapters

- 0:00 Places hidden in free text
- 0:48 Address and Geolocation modules
- 2:31 Installing the modules with Composer
- 4:21 Address field with a map display
- 6:58 Installing AI Interpolator OpenAI
- 8:37 The text address finder rule
- 9:55 Checking places with Google Places
- 11:21 Cost and the plotted map

## Transcript

YouTube's automatic captions, lightly corrected. Click a line to jump to that moment in the video.

### Transcript

- 0:00 hey there Marcus here um so today's workflow is um a pretty complex and simple one at the same time or rather it's pretty simple to solve it it would be very complex to do it
- 0:13 manually uh so say that I have a site with a lot of uh location reviews for instance so you see here 10 best restaurants in Berlin this is just a spoof article now with some title and
- 0:27 some descriptions uh of 10 restaurants in Berlin right and it's just stored in a Big Blob field so say that I have thousands of this and I just realized oh it would be so nice to have Google
- 0:40 Maps on this page for each of these right so you can actually see on a map the location of it uh and this is not very hard to solve in Drupal because there are very nice um
- 0:56 modules for that namely the uh address add module and the geolocation field module so address module for storing the actual addresses and geolocation modules for uh plotting them out on a map so
- 1:12 that's very solvable the problem is of course if you have thousands of Articles someone is going to have to go in and you know literally search for it in Google maps and copy and paste and yeah
- 1:24 it takes forever you can have a maybe a a working student or Mechanical Turk or something doing it but that will take a lot of time and cost money um so what if we could use AI to
- 1:40 automate this and this is what I'm going to show today basically with a AI Interpolator OpenAI module uh that I built so uh what you see in front of you it's just standardized
- 1:53 Drupal uh uh installation or sorry the standard profile Drupal installation uh I've taken the article content type and just added basically this blob field uh I added the admin module but
- 2:08 otherwise I haven't touched anything it's just set up now right um so we can start by just setting up the Google Maps field so how you would do that uh you know how how you do that
- 2:25 basically so someone manually can input this uh uh we will start with that basically so what we do is we get the address module um so we just copy this composer
- 2:40 command and we just run this uh and this is just going to get the address module with all its dependencies um oh sorry I'm running this in Docksal so I have to prepend with fin
- 2:54 um so I I basically run it inside the container of my local developer environment so but um yeah the composer command is the important thing and this gets all the dependencies that it
- 3:07 needs uh we're going to do the same with geolocation field take the latest stable version so I just do that and then we're just going to go ahead and install those so I'm going to
- 3:22 log in then as administrator uh on my website click extend to get the modules and what we need now now then is we need the address module we need geolocation geolocation
- 3:35 address we also need the Google Maps module to show it and Google Places API to basically uh be able to figure out the latitude longitude uh for the addresses uh after we install those the
- 3:52 first thing uh that we have to do is to make sure that the uh geolocation module has the uh Google Maps API key so that's under web services Google Maps API settings you just paste it in there
- 4:07 I'm going to drag it out of you now so you don't see my API key and you just click save and then uh that's it so now I have saved it here the next step that we need is to go
- 4:24 to our content type that's the article then manage fields and we're just going to add a address field then and this is where we store the locations uh and since we don't know exactly how
- 4:40 many uh address Fields we're going to store because maybe I have article that's the I don't know top 100 ramen places in New York or something uh on another page I don't know exact number
- 4:53 so we just set it to unlimited we hide first name middle name and last name because that's not needed for a restaurant or for a um yeah company location we just save this then
- 5:10 we go to manage display so we can change this to a uh map field we're going to enable labels so you can see the name of the restaurants in this case and we're going to use uh
- 5:24 replacement pattern to show that which is the organization name we just paste that in there yeah Fit locations is okay sorry I just had to think a little bit but we need to use the Google Places API
- 6:08 for geocoding in this case as well yes update this save so now if sorry if we go to our content there will be a field called the location here so this is basically how
- 6:26 to get the actual map field there in Drupal now we could go ahead and do manual stuff so I could go and find now then Germany and then you know uh find this Tim Raue in Google
- 6:44 Maps search for it and copy and paste the address postal code city and add another add another add another but that of course would take a very long time so that's where the AI Interpolator OpenAI
- 6:59 come in because you can see it has a plug in for the address field here um and that's what we're going to use so I just go ahead and install this now so first fetch it and then we're
- 7:18 going to install it here so we have in AI Interpolator address and that need requires all the other modules here it's going to install the OpenAI Core module and this will warn us now that we
- 7:35 have to set up a API key uh you can also find this under here but same thing again I'm just pulling it to the side here copy and pasting the API key so you guys don't
- 7:51 see it and then it's back here uh then I also have under uh configuration here let's see what happened there configuration web service Google Places config I have to paste API key
- 8:10 again um because there's no hard requirement that you have uh the Google Maps uh or geolocation module uh just to get the address field working so this is for the AI
- 8:26 interpolator it's needed a second time right and this is a password field so I can paste it here without you guys seeing it uh after I've done this we're going to do the magic now then so we just go
- 8:39 back to article manage Fields click on the location field and now there will be an enable AI Interpolator checkbox here with a field rule text address finder um I'm just going to copy the
- 8:55 placeholder example because that's pretty close what we want to do so from the content text find all geographical places that exist that can be ploted on Google Maps this is not completely
- 9:06 correct because if we go to the article I will show you why that will search the whole text right and if we have this 893 rot it talks about the chef's other place K Ramen and we don't want to plot
- 9:22 that one right because that is not in the top list so because of that what we're going to write instead from the content text find all geographical places that exists in
- 9:38 the headers of the text and that can be plotted on Google Maps because these are headers right um and instead of the context here I'm going to use the raw context and that
- 9:53 means that it comes with HTML so basically what's going to happen now in the background is that uh we're going to ask OpenAI to give search word for Google Maps right uh or we can do in city so
- 10:13 it's going to find um search words from Google Maps and it's going to use Google Places API to search for these to find actual places and this is the way that we can verify that the AI is not
- 10:26 hallucinating right um so this will make sure that it is the all yeah it will also make sure that it is the actual correct address because we take the addresses from Google Places H
- 10:40 API which is very trustworthy so we have to use the article as the base field so that's what's getting replaced here in raw context right under advanced settings we don't really have to do
- 10:52 anything there because we're not going to chain anything this is the only thing we do we need to switch to GPT-4 though because we need uh we need a smarter AI basically it's a
- 11:05 pretty complex process this so we just go ahead and save that and then we go into our article here and I'm just going to resave it and now it's going to do exactly what I talked
- 11:18 about so uh I will be honest to you also here of course there's a cost to OpenAI of some sense for this article well it's not sent it's under a sent I think actually and there is a cost to Google
- 11:34 Places API which is also in the scent range uh to figure everything out now uh but you know compar comparing to hire someone to do this manually that's nothing plus it's done in as you can see
- 11:50 it's like 20 seconds if we scroll down what do we see well we have a lot of places here this we can make nicer of course right now it just chose the title here right I maybe I zoomed in a little bit
- 12:05 too much but you can see it's show showing the places at their locations and then I will just click on edit so you will see that the actual data I stored here um yeah Tim for instance it's at
- 12:22 rud 26 this is something you can verify that these are correct addresses and they will never be wrong because they come from Google places right um and yeah that's it basically as
- 12:37 I said before everything is open source you can try out this uh workflow yourself after you watched it here um yeah thank you for watching and uh Happy developing

  Filed under [Workflows](/blog?category=6) [Drupal AI](/blog?category=2)

Parts of this content were produced by AI.

This site has not assessed whether a label is required for this content.

  How was AI used?The video and the introduction are Marcus's own, first published on workflows-of-ai.com. AI wrote the subtitle, the summary and the video chapters from the transcript, and corrected misheard names in YouTube's automatic captions.

   Marcus Johansson

Tinkers with AI and Drupal

 [About Marcus](/about/marcus-johansson)[Drupal.org profile](https://www.drupal.org/u/marcus_johansson)[Drupal AI](https://www.drupal.org/project/ai)

## The post in three sentences

A spoof article about the 10 best restaurants in Berlin gets an unlimited address field, shown as a Google Map with the Address and Geolocation modules. The AI Interpolator OpenAI text address finder rule asks GPT-4 for the places in the headers and looks each one up in the Google Places API, so the addresses are real. A run takes about 20 seconds and costs less than a cent in OpenAI plus a few cents for Google Places.