Giter Club home page Giter Club logo

br-address-parser's Introduction

br-address-parser

This module is a simple parser for Brazilian addresses. This receives a complete address string and split it in 'street', 'number', 'complement', 'neighborhood', 'city' and 'state'.

This code is a br-address-parser port for Python. Credits should go to the original implementation contributors.

How to install

pip install br_address_parser

How to use

from br_address_parser import parse

complete_address = "Av. Brasil, 1245 - Bloco 2 Ap 203 - Centro - Belo Horizonte - MG"
parsed_address = parse(complete_address)

The above example transforms the string "Av. Brasil, 1245 - Bloco 2 Ap 203 - Centro - Belo Horizonte - MG" into the following object:

{
    "street": "Av. Brasil",
    "number": "1245",
    "complement": "Bloco 2 Ap 203",
    "neighborhood": "Centro",
    "city": "Belo Horizonte",
    "state": "MG"
}

If you want to fill some fields with default values when they are empty, then you can use defaultFields parameter:

complete_address = "AV ANAVILLE 1-QD 3 LT 4 - RESIDENCIAL ANAVILLE - ANAPOLIS - GO"
parsed_address = parse(complete_address, {"number": "S/N"})

The above example transforms will put S/N in the number field, because parsed address returns empty number:

{
   "street": "AV ANAVILLE 1",
   "number": "S/N",
   "complement": "QD 3 LT 4",
   "neighborhood": "RESIDENCIAL ANAVILLE",
   "city": "ANAPOLIS",
   "state": "GO"
}

When the address cannot be parsed, the parse function returns None.

How to test

make test

License

This project is licensed under the terms of the MIT license.

br-address-parser's People

Contributors

huberemanuel avatar

Stargazers

Alex James avatar

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.