---
title: "Find real locations from text"
video_id: irHTd8IV6Jk
url: https://www.youtube.com/watch?v=irHTd8IV6Jk
workflow_page: https://workflows-of-ai.com/workflow/find-real-locations-text
language: en
captions: generated
---

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