Extract street address from a string

2024/9/20 21:32:17

Is there any way to extract a street address from a string (say, email) using python? The address does not come in a set format. It can come without state, zip code, city, but I can guess and supply these parameters if they are missing. Also, the address may be represented by a corner of two streets. Once I extract the address, I want to send it to Google Map or other similar service to get back the real, formatted address.

It doesn't need to be 100% accurate, but is there any library to do that? If it doesn't exist, how should I start?

Answer

As you already say yourself, an address can come in a large number of formats. And the reality is actually even worse if you take addresses from other countries into account. So no, there is not really a good way to parse and clean up such addresses. The larger the regional area is you want to include as possible formats, the more complicated it gets.

If you want to send the address to Google Maps anyway, then just send your original format. Google has enough data to extract the more useful parts and make the best possible out of it. As you are sending it to Google anyway, you can just do it in the first place.

https://en.xdnf.cn/q/119287.html

Related Q&A

Convert list in String format back to list of float numbers

str = [ 3.82133931e-01 4.27354313e-02 1.94678816e-03 0.00000000e+000.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+000.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e…

Hawaiian Pronunciation [duplicate]

This question already has an answer here:Hawaiian pronouncer(1 answer)Closed 1 year ago.Hitting a snag with an assignment and thought Id ask for help. The goal is to be able to pronounce Hawaiian words…

mutiline python script in html (pyscript)

Ive tried to use pyscript in html but i can only get it to work in one line of code can somebody help me get it to work for the following code? def vpn(website):from selenium import webdriverfrom sele…

How to write an output of a command to stdout and a file in Python3?

I have a Windows command which I want to write to stdout and to a file. For now, I only have 0 string writen in my file:#!/usr/bin/env python3 #! -*- coding:utf-8 -*-import subprocesswith open(auto_cha…

Mongodb adding a new field in an existing document, with specific position

I am facing this issue where I need to insert a new field in an existing document at a specific position. Sample document: { "name": "user", "age" : "21", "…

how to check every 3 x 3 box in sudoku?

I am trying to build a sudoku solver without much googling around. Right now, I am working on a function to test whether the board is valid, which I will use later in a loop. This is what the function …

multiple model accuracy json result format using python

I am building a multiple model and i am getting results with 7 models accuracy, i need those results with a proper json format.My multiple model building code will be like thisseed = 7"prepare mod…

Calculate Time Difference based on Conditionals

I have a dataframe that looks something like this (actual dataframe is millions of rows):ID Category Site Task Completed Access Completed1 A X 1/2/22 12:00:00AM 1/1/22 12:00:00 AM1 A Y 1/3/22 12:00:00A…

Cannot open jpg images with PIL or open()

I am testing to save ImageField in Django, but for some reason all the *.jpg files Ive tried dont work while the one png I had works. Using django shell in WSL VCode terminal. python 3.7 django 3.0 pil…

how to delete tensorflow model before retraining

I cant retrain my image classifier with new images, I get the following error:AssertionError: Export directory already exists. Please specify a different export directory: /tmp/saved_models/1/How do I …