Giter VIP home page Giter VIP logo

parse-address's Introduction

US Street Address Parser Build Status

This is Node.js port for Perl Geo::StreetAddress::US package

Description from Geo::StreetAddress::US:

Geo::StreetAddress::US is a regex-based street address and street intersection parser for the United States. Its basic goal is to be as forgiving as possible when parsing user-provided address strings. Geo::StreetAddress::US knows about directional prefixes and suffixes, fractional building numbers, building units, grid-based addresses (such as those used in parts of Utah), 5 and 9 digit ZIP codes, and all of the official USPS abbreviations for street types and state names... more

Usage:

//from node:
npm install parse-address
var parser = require('parse-address'); 
var parsed = parser.parseLocation('1005 N Gravenstein Highway Sebastopol CA 95472');

//from browser:
<script type="text/javascript" src="./parse-address.min.js"></script>
var parsed = parseAddress.parseLocation('1005 N Gravenstein Highway Sebastopol CA 95472');

//Parsed address:
{
 number: '1005',
 prefix: 'N',
 street: 'Gravenstein',
 type: 'Hwy',
 city: 'Sebastopol',
 state: 'CA',
 zip: '95472' }

parse-address's People

Contributors

alechirsch avatar cecilia-donnelly avatar fabiomcosta avatar hassansin avatar jgimbel avatar knaopel avatar nikmolnar avatar varadara avatar yankeeinlondon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

parse-address's Issues

No test reporting

I noticed your tests don't have any output, do you prefer it like that or would you like a PR?

Also, can you provide a test case for:

TODO:
Freeform Address parser

Parser is extremely slow

I am trying to use this package to parse a large amount of GIS data on a node server, and I'm running into an issue in that parseLocation takes almost 500 milliseconds to parse just one string. As I need to parse upwards of 10,000 strings for each data set, this creates quite a hangup on my server!

My use cases all look something like parseLocation('NW GRANT AV') -- in each case I just need to separate out the directional prefix and street type from the street name. Am I doing something wrong which is causing it to take this long, or is this just the approximate expected time for the parser to complete?

Thanks in advance for any response.

Feature Request: skip address normalization step

When using the address parser, I would like an option for skipping the abbreviating of address components like state and street type.

For example:

var parser = require('parse-address');
var parsed = parser.parseLocation('1005 N Gravenstein Highway Sebastopol CA 95472');

// produces...
{ number: '1005',
  prefix: 'N',
  street: 'Gravenstein',
  type: 'Hwy',
  city: 'Sebastopol',
  state: 'CA',
  zip: '95472' }

With the new feature, all sub-strings would remain unmodified if desired:

var parser = require('parse-address');
var parsed = parser.parseLocation('1005 N Gravenstein Highway Sebastopol CA 95472',
                                  skipAbbrev=true); // or some other flag to skip abbreviation

// produces...
{ number: '1005',
  prefix: 'N',
  street: 'Gravenstein',
  type: 'Highway', // doesn't abbreviate
  city: 'Sebastopol',
  state: 'CA', // leaves abbreviated
  zip: '95472' }

Fails to parse certain US address (Like the ones on Highways)

We are using this library in our application. Has worked fairly well for most of the US addresses, however fails for certain unusual valid ones like - "N95W18000 Appleton Ave, Menomonee Falls, WI 53051" or other highway addresses. Can this library be enhanced to handle those ?

Add a license file

Hi! Here it says that this package is being distributed under the ISC license -- is that true? If so, would you accept a pull request to add a file with the text of the license and some license headers?

Thanks!

P.S. -- excited to use the library, thanks for porting it to node js!

[Bug] Parses following address incorrectly "'4505 ravenwood pl union city ga"

Parsing of 4505 ravenwood pl union city ga results in

{
  "number": "4505",
  "street": "ravenwood pl",
  "type": "Un",
  "city": "city",
  "state": "ga"
}

while it should be

{
  "number": "4505",
  "street": "ravenwood",
  "type": "pl",
  "city": "union city",
  "state": "ga"
}

Adding , after street name helps, but it's not always possible.

Certain addresses in Alaska, USA are showing strange behavior

Hi,

I've been using this package in my application and it works great for most of the US addresses. However, I recently figured out that certain addresses in the US state of Alaska are causing this to break.

For example:
"HC 60 Box 2840, Haines, AK 99827" is a valid address in Alaska. But parsing it is only returning Street. I get the following response:

{street: "hc"}

Can this be looked into? Thanks a million!

Unit test fails

The test fails when there is a country in the address, but without a country, it works perfectly.
Example:
Fails to parse the address correctly - 6516 East Calle Bellatrix, Tucson, AZ 85710, USA
Pass: 6516 East Calle Bellatrix, Tucson, AZ 85710

Using # as secondary designator results in inconsistent behavior

We have an html input for address entry. We use Google Maps Autocomplete to provide suggestions. Google Maps doesn't handle secondary designators very well during interactive input, so we use parse-address to remove the secondary designator. For this reason, it's important that parse-address acts consistently with partial input (as the user is typing).

Input: "10 miller pl Unit 505, san fran"
Output: {"number":"10","street":"miller","type":"Pl","sec_unit_type":"Unit","sec_unit_num":"505"}
Comment: Correctly identifies secondary information as "Unit 505"

However--

Input: "10 miller pl #505, san fran"
Output: {"number":"10","street":"miller","type":"Pl"}
Comment: Does not correctly identify secondary information as "#505" until the entire address is completely entered.

Input: "10 miller pl #505, san francisco, ca"
Output: {"number":"10","street":"miller","type":"Pl","sec_unit_type":"Unit","sec_unit_num":"505"}
Comment: Correctly identifies all components.

Documentation when parsed is null?

What causes parsed to return null. For validation purposes.
I suppose when var parts = XRegExp.exec(address,Addr_Match.informal_address); returns null?

Doesn't identify 9 digit zips

If I type 90291-3064 in as the address (either by itself or at the end of a street address) I'd expect the parser to be able to identify this as a Zip+4 format but instead it either truncates the +4 part of the zip when it is hanging off a street address or associates the +4 part as being a street number.

Undefined is not a function.

Running parseLocation inside a React app that a submodule inside a larger Gatsby project.

Getting a strange error when using parser.parseLocation(value). Browser is returning 'undefined is not a function.' Line 521 of parseaddress/address.js. Here's the full block:

    Addr_Match = {
      type    : flatten(Street_Type).sort().filter(function(v,i,arr){return arr.indexOf(v)===i }).join('|'),
      fraction : '\\d+\\/\\d+',
      state   : '\\b(?:' + keys(State_Code).concat(values(State_Code)).map(XRegExp.escape).join('|') + ')\\b',
      direct  : values(Directional).sort(function(a,b){return a.length < b.length}).reduce(function(prev,curr){return prev.concat([XRegExp.escape(curr.replace(/\w/g,'$&.')),curr])},keys(Directional)).join('|'),
      dircode : keys(Direction_Code).join("|"),
      zip     : '(?<zip>\\d{5})[- ]?(?<plus4>\\d{4})?',
      corner  : '(?:\\band\\b|\\bat\\b|&|\\@)',
    };

I suspect it's related to how XRegExp is being required at the top of the same file:

   XRegExp = __webpack_require__(/*! xregexp/src/xregexp.js */ "./node_modules/xregexp/src/xregexp.js");

Encounter a similar issue when running parser.parseAddress(value). Browser returns error: 'XRegExp.exec is not a function'. Line 682 of parseaddress/address.js:

  parser.parseAddress = function(address){
    lazyInit();
    var parts = XRegExp.exec(address,Addr_Match.address);
    return parser.normalize_address(parts);
  };

I've confirmed that xregexp is also an installed dependency.

Please advice when you get a chance, thanks!

Issue when it find 2 possible street type

When the script find a address with 2 possible street type, it grabs the first one as street type and not the last. Blvd should be considered the street type, and not Beach, but it is now ignored and left as part of the City name

760 South Beach Blvd La Habra, CA 90631-6416

the result is

{ "number": "760", "street": "South", "type": "Bch", "city": "Blvd La Habra", "state": "CA", "zip": "90631", "plus4": "6416" }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.