Sha256: 64bd70b3909d73a141aab7b18e5aefea9b531c538b7a0ec7f01f64e597cd8562

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require_relative 'japanese_address_parser/address_parser'
require_relative 'japanese_address_parser/version'
require_relative 'japanese_address_parser/normalize_japanese_addresses_schmoozer'

module JapaneseAddressParser
  JS_PACKAGE_PATH = ::File.expand_path('../js', __dir__)
  public_constant :JS_PACKAGE_PATH

  module_function

  def call(full_address)
    # https://github.com/geolonia/normalize-japanese-addresses を使って住所を正規化する。
    normalize_japanese_addresses = ::JapaneseAddressParser::NormalizeJapaneseAddressesSchmoozer.new(::JapaneseAddressParser::JS_PACKAGE_PATH)
    result = normalize_japanese_addresses.normalize(full_address)

    # このライブラリで探索するのは町域まで。
    # それ以降のデータを使って探索するとデータと名前が一致しないことがあるので、町域までのデータを使う。
    ::JapaneseAddressParser::AddressParser.call("#{result['pref']}#{result['city']}#{result['town']}")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
japanese_address_parser-2.0.0 lib/japanese_address_parser.rb