atlas_engine 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +123 -0
- data/Rakefile +20 -0
- data/app/assets/config/atlas_engine_manifest.js +3 -0
- data/app/assets/stylesheets/atlas_engine/application.css +15 -0
- data/app/concerns/atlas_engine/handles_blob.rb +26 -0
- data/app/concerns/atlas_engine/handles_interruption.rb +22 -0
- data/app/controllers/atlas_engine/application_controller.rb +7 -0
- data/app/controllers/atlas_engine/connectivity_controller.rb +21 -0
- data/app/controllers/atlas_engine/country_imports_controller.rb +73 -0
- data/app/controllers/atlas_engine/graphql_controller.rb +59 -0
- data/app/countries/atlas_engine/ar/country_profile.yml +9 -0
- data/app/countries/atlas_engine/at/address_importer/corrections/open_address/city_corrector.rb +23 -0
- data/app/countries/atlas_engine/at/country_profile.yml +24 -0
- data/app/countries/atlas_engine/at/index_configuration.yml +63 -0
- data/app/countries/atlas_engine/at/synonyms.yml +6 -0
- data/app/countries/atlas_engine/at/validation_transcriber/address_parser.rb +58 -0
- data/app/countries/atlas_engine/au/address_importer/open_address/filter.rb +26 -0
- data/app/countries/atlas_engine/au/address_importer/open_address/mapper.rb +41 -0
- data/app/countries/atlas_engine/au/country_profile.yml +13 -0
- data/app/countries/atlas_engine/au/synonyms.yml +209 -0
- data/app/countries/atlas_engine/au/validation_transcriber/address_parser.rb +121 -0
- data/app/countries/atlas_engine/be/country_profile.yml +12 -0
- data/app/countries/atlas_engine/bm/address_importer/corrections/open_address/city_alias_corrector.rb +38 -0
- data/app/countries/atlas_engine/bm/address_importer/open_address/mapper.rb +40 -0
- data/app/countries/atlas_engine/bm/country_profile.yml +12 -0
- data/app/countries/atlas_engine/br/country_profile.yml +4 -0
- data/app/countries/atlas_engine/ca/country_profile.yml +7 -0
- data/app/countries/atlas_engine/ca/synonyms.yml +1615 -0
- data/app/countries/atlas_engine/ch/address_importer/corrections/open_address/city_corrector.rb +29 -0
- data/app/countries/atlas_engine/ch/address_importer/corrections/open_address/locale_corrector.rb +74 -0
- data/app/countries/atlas_engine/ch/address_importer/open_address/mapper.rb +40 -0
- data/app/countries/atlas_engine/ch/country_profile.yml +15 -0
- data/app/countries/atlas_engine/ch/locales/de/country_profile.yml +15 -0
- data/app/countries/atlas_engine/ch/locales/de/index_configuration.yml +63 -0
- data/app/countries/atlas_engine/ch/locales/de/synonyms.yml +7 -0
- data/app/countries/atlas_engine/ch/locales/fr/synonyms.yml +21 -0
- data/app/countries/atlas_engine/cz/country_profile.yml +6 -0
- data/app/countries/atlas_engine/de/country_profile.yml +19 -0
- data/app/countries/atlas_engine/de/index_configuration.yml +64 -0
- data/app/countries/atlas_engine/de/synonyms.yml +2 -0
- data/app/countries/atlas_engine/de/validation_transcriber/address_parser.rb +19 -0
- data/app/countries/atlas_engine/dk/country_profile.yml +6 -0
- data/app/countries/atlas_engine/dk/synonyms.yml +3 -0
- data/app/countries/atlas_engine/dk/validation_transcriber/address_parser.rb +21 -0
- data/app/countries/atlas_engine/fo/country_profile.yml +5 -0
- data/app/countries/atlas_engine/fr/address_importer/corrections/open_address/city_corrector.rb +28 -0
- data/app/countries/atlas_engine/fr/country_profile.yml +13 -0
- data/app/countries/atlas_engine/fr/synonyms.yml +21 -0
- data/app/countries/atlas_engine/fr/validation_transcriber/address_parser.rb +34 -0
- data/app/countries/atlas_engine/gb/address_validation/es/query_builder.rb +98 -0
- data/app/countries/atlas_engine/gb/country_profile.yml +10 -0
- data/app/countries/atlas_engine/gb/validation_transcriber/full_address_parser.rb +164 -0
- data/app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb +120 -0
- data/app/countries/atlas_engine/gg/address_validation/validators/full_address/restrictions/unsupported_city.rb +39 -0
- data/app/countries/atlas_engine/gg/country_profile.yml +7 -0
- data/app/countries/atlas_engine/ie/country_profile.yml +3 -0
- data/app/countries/atlas_engine/it/address_importer/corrections/open_address/city_corrector.rb +27 -0
- data/app/countries/atlas_engine/it/address_importer/corrections/open_address/province_corrector.rb +29 -0
- data/app/countries/atlas_engine/it/address_importer/open_address/mapper.rb +42 -0
- data/app/countries/atlas_engine/it/country_profile.yml +11 -0
- data/app/countries/atlas_engine/jp/address_validation/es/data_mapper.rb +63 -0
- data/app/countries/atlas_engine/jp/country_profile.yml +6 -0
- data/app/countries/atlas_engine/kr/address_importer/open_address/mapper.rb +41 -0
- data/app/countries/atlas_engine/kr/country_profile.yml +11 -0
- data/app/countries/atlas_engine/li/address_importer/corrections/open_address/city_corrector.rb +25 -0
- data/app/countries/atlas_engine/li/country_profile.yml +21 -0
- data/app/countries/atlas_engine/li/index_configuration.yml +63 -0
- data/app/countries/atlas_engine/li/synonyms.yml +6 -0
- data/app/countries/atlas_engine/lt/country_profile.yml +6 -0
- data/app/countries/atlas_engine/lt/synonyms.yml +7 -0
- data/app/countries/atlas_engine/lt/validation_transcriber/address_parser.rb +24 -0
- data/app/countries/atlas_engine/lu/address_importer/corrections/open_address/locale_corrector.rb +54 -0
- data/app/countries/atlas_engine/lu/country_profile.yml +12 -0
- data/app/countries/atlas_engine/nl/address_importer/corrections/open_address/city_corrector.rb +25 -0
- data/app/countries/atlas_engine/nl/country_profile.yml +18 -0
- data/app/countries/atlas_engine/nl/index_configuration.yml +52 -0
- data/app/countries/atlas_engine/nl/synonyms.yml +92 -0
- data/app/countries/atlas_engine/nl/validation_transcriber/address_parser.rb +85 -0
- data/app/countries/atlas_engine/no/country_profile.yml +5 -0
- data/app/countries/atlas_engine/nz/country_profile.yml +3 -0
- data/app/countries/atlas_engine/pl/country_profile.yml +5 -0
- data/app/countries/atlas_engine/pl/validation_transcriber/address_parser.rb +19 -0
- data/app/countries/atlas_engine/pt/address_importer/corrections/open_address/city_corrector.rb +32 -0
- data/app/countries/atlas_engine/pt/address_importer/open_address/mapper.rb +39 -0
- data/app/countries/atlas_engine/pt/country_profile.yml +10 -0
- data/app/countries/atlas_engine/pt/synonyms.yml +7 -0
- data/app/countries/atlas_engine/sa/country_profile.yml +10 -0
- data/app/countries/atlas_engine/se/country_profile.yml +5 -0
- data/app/countries/atlas_engine/tt/address_importer/open_address/mapper.rb +38 -0
- data/app/countries/atlas_engine/tt/country_profile.yml +7 -0
- data/app/countries/atlas_engine/us/country_profile.yml +12 -0
- data/app/countries/atlas_engine/us/synonyms.yml +350 -0
- data/app/graphql/atlas_engine/errors/locale_unsupported_error.rb +17 -0
- data/app/graphql/atlas_engine/schema.graphql +1293 -0
- data/app/graphql/atlas_engine/schema.rb +23 -0
- data/app/graphql/atlas_engine/types/address_validation/address_input.rb +51 -0
- data/app/graphql/atlas_engine/types/address_validation/concern_type.rb +20 -0
- data/app/graphql/atlas_engine/types/address_validation/enums/concern_enum.rb +15 -0
- data/app/graphql/atlas_engine/types/address_validation/field_type.rb +15 -0
- data/app/graphql/atlas_engine/types/address_validation/suggestion_type.rb +21 -0
- data/app/graphql/atlas_engine/types/base_argument.rb +9 -0
- data/app/graphql/atlas_engine/types/base_enum.rb +9 -0
- data/app/graphql/atlas_engine/types/base_field.rb +10 -0
- data/app/graphql/atlas_engine/types/base_input_object.rb +9 -0
- data/app/graphql/atlas_engine/types/base_interface.rb +10 -0
- data/app/graphql/atlas_engine/types/base_object.rb +9 -0
- data/app/graphql/atlas_engine/types/base_scalar.rb +9 -0
- data/app/graphql/atlas_engine/types/base_union.rb +9 -0
- data/app/graphql/atlas_engine/types/matching_strategy_type.rb +12 -0
- data/app/graphql/atlas_engine/types/mutation_type.rb +9 -0
- data/app/graphql/atlas_engine/types/query_type.rb +61 -0
- data/app/graphql/atlas_engine/types/validation_supported_country.rb +12 -0
- data/app/graphql/atlas_engine/types/validation_type.rb +22 -0
- data/app/helpers/atlas_engine/address_importer/import_log_helper.rb +66 -0
- data/app/helpers/atlas_engine/application_helper.rb +7 -0
- data/app/helpers/atlas_engine/locale_format_helper.rb +40 -0
- data/app/helpers/atlas_engine/log_base.rb +32 -0
- data/app/helpers/atlas_engine/log_helper.rb +24 -0
- data/app/helpers/atlas_engine/metrics_helper.rb +25 -0
- data/app/jobs/atlas_engine/address_importer/clear_records_job.rb +39 -0
- data/app/jobs/atlas_engine/address_importer/open_address/geo_json_import_job.rb +212 -0
- data/app/jobs/atlas_engine/address_importer/open_address/geo_json_import_launcher_job.rb +67 -0
- data/app/jobs/atlas_engine/address_importer/open_address/prepares_geo_json_file.rb +41 -0
- data/app/jobs/atlas_engine/address_importer/resumable_import_job.rb +49 -0
- data/app/jobs/atlas_engine/address_importer/street_backfill_job.rb +63 -0
- data/app/jobs/atlas_engine/application_job.rb +10 -0
- data/app/jobs/atlas_engine/concerns/address_importer/handles_errors.rb +43 -0
- data/app/lib/atlas_engine/concern_formatter.rb +40 -0
- data/app/lib/atlas_engine/restrictions/base.rb +20 -0
- data/app/lib/atlas_engine/restrictions/unsupported_script.rb +31 -0
- data/app/lib/atlas_engine/validation_transcriber/address_parser_base.rb +201 -0
- data/app/lib/atlas_engine/validation_transcriber/address_parser_factory.rb +27 -0
- data/app/lib/atlas_engine/validation_transcriber/address_parser_north_america.rb +39 -0
- data/app/lib/atlas_engine/validation_transcriber/address_parser_oceanic.rb +17 -0
- data/app/lib/atlas_engine/validation_transcriber/address_parser_preprocessor.rb +132 -0
- data/app/lib/atlas_engine/validation_transcriber/address_parsing_helper.rb +38 -0
- data/app/lib/atlas_engine/validation_transcriber/address_parsings.rb +54 -0
- data/app/lib/atlas_engine/validation_transcriber/constants.rb +50 -0
- data/app/lib/atlas_engine/validation_transcriber/english_street_parser.rb +59 -0
- data/app/lib/atlas_engine/validation_transcriber/formatter.rb +46 -0
- data/app/lib/atlas_engine/validation_transcriber/french_street_parser.rb +50 -0
- data/app/lib/atlas_engine/validation_transcriber/province_code_normalizer.rb +45 -0
- data/app/lib/atlas_engine/validation_transcriber/street_parser.rb +18 -0
- data/app/lib/atlas_engine/validation_transcriber/zip_normalizer.rb +23 -0
- data/app/mailers/atlas_engine/application_mailer.rb +9 -0
- data/app/models/atlas_engine/address_importer/corrections/corrector.rb +33 -0
- data/app/models/atlas_engine/address_importer/import_events_notifier/base.rb +35 -0
- data/app/models/atlas_engine/address_importer/import_events_notifier/notifier.rb +26 -0
- data/app/models/atlas_engine/address_importer/open_address/default_mapper.rb +46 -0
- data/app/models/atlas_engine/address_importer/open_address/feature_helper.rb +110 -0
- data/app/models/atlas_engine/address_importer/open_address/filter.rb +17 -0
- data/app/models/atlas_engine/address_importer/open_address/loader.rb +27 -0
- data/app/models/atlas_engine/address_importer/open_address/transformer.rb +39 -0
- data/app/models/atlas_engine/address_importer/open_address.rb +10 -0
- data/app/models/atlas_engine/address_importer/validation/base_validator.rb +86 -0
- data/app/models/atlas_engine/address_importer/validation/default_validator.rb +27 -0
- data/app/models/atlas_engine/address_importer/validation/field_validations/city.rb +47 -0
- data/app/models/atlas_engine/address_importer/validation/field_validations/interface.rb +29 -0
- data/app/models/atlas_engine/address_importer/validation/field_validations/province.rb +73 -0
- data/app/models/atlas_engine/address_importer/validation/field_validations/zip.rb +84 -0
- data/app/models/atlas_engine/address_importer/validation/validator.rb +17 -0
- data/app/models/atlas_engine/address_importer/validation/wrapper.rb +70 -0
- data/app/models/atlas_engine/address_number.rb +36 -0
- data/app/models/atlas_engine/address_number_range.rb +200 -0
- data/app/models/atlas_engine/address_validation/abstract_address.rb +49 -0
- data/app/models/atlas_engine/address_validation/address.rb +47 -0
- data/app/models/atlas_engine/address_validation/candidate.rb +109 -0
- data/app/models/atlas_engine/address_validation/candidate_tuple.rb +15 -0
- data/app/models/atlas_engine/address_validation/concern.rb +74 -0
- data/app/models/atlas_engine/address_validation/concern_producer.rb +19 -0
- data/app/models/atlas_engine/address_validation/concern_queue.rb +20 -0
- data/app/models/atlas_engine/address_validation/concern_record.rb +122 -0
- data/app/models/atlas_engine/address_validation/datastore_base.rb +27 -0
- data/app/models/atlas_engine/address_validation/errors.rb +13 -0
- data/app/models/atlas_engine/address_validation/es/candidate_selector.rb +70 -0
- data/app/models/atlas_engine/address_validation/es/data_mappers/decompounding_data_mapper.rb +39 -0
- data/app/models/atlas_engine/address_validation/es/data_mappers/default_data_mapper.rb +110 -0
- data/app/models/atlas_engine/address_validation/es/datastore.rb +229 -0
- data/app/models/atlas_engine/address_validation/es/default_query_builder.rb +30 -0
- data/app/models/atlas_engine/address_validation/es/query_builder.rb +160 -0
- data/app/models/atlas_engine/address_validation/es/term_vectors.rb +78 -0
- data/app/models/atlas_engine/address_validation/es/validators/full_address.rb +123 -0
- data/app/models/atlas_engine/address_validation/es/validators/full_address_street.rb +18 -0
- data/app/models/atlas_engine/address_validation/es/validators/restriction_evaluator.rb +37 -0
- data/app/models/atlas_engine/address_validation/field.rb +30 -0
- data/app/models/atlas_engine/address_validation/full_address_validator_base.rb +27 -0
- data/app/models/atlas_engine/address_validation/log_emitter.rb +66 -0
- data/app/models/atlas_engine/address_validation/matching_strategies.rb +16 -0
- data/app/models/atlas_engine/address_validation/normalizer.rb +38 -0
- data/app/models/atlas_engine/address_validation/predicate_pipeline.rb +80 -0
- data/app/models/atlas_engine/address_validation/request.rb +12 -0
- data/app/models/atlas_engine/address_validation/result.rb +154 -0
- data/app/models/atlas_engine/address_validation/runs_validation.rb +16 -0
- data/app/models/atlas_engine/address_validation/session.rb +47 -0
- data/app/models/atlas_engine/address_validation/statsd_emitter.rb +72 -0
- data/app/models/atlas_engine/address_validation/strategies.rb +10 -0
- data/app/models/atlas_engine/address_validation/suggestion.rb +97 -0
- data/app/models/atlas_engine/address_validation/token/comparator.rb +44 -0
- data/app/models/atlas_engine/address_validation/token/comparison.rb +76 -0
- data/app/models/atlas_engine/address_validation/token/sequence/comparator.rb +158 -0
- data/app/models/atlas_engine/address_validation/token/sequence/comparison.rb +166 -0
- data/app/models/atlas_engine/address_validation/token/sequence.rb +147 -0
- data/app/models/atlas_engine/address_validation/token/synonyms.rb +77 -0
- data/app/models/atlas_engine/address_validation/token.rb +113 -0
- data/app/models/atlas_engine/address_validation/validator.rb +147 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/address_comparison.rb +97 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/candidate_result.rb +164 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/candidate_result_base.rb +46 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/comparison_helper.rb +135 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/components_to_validate.rb +88 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb +127 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/exclusions/exclusion_base.rb +23 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/invalid_zip_concern_builder.rb +42 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/invalid_zip_for_country_concern.rb +37 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/invalid_zip_for_province_concern.rb +37 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/no_candidate_result.rb +26 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/number_comparison.rb +31 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/postal_code_matcher.rb +60 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/result_updater.rb +42 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/suggestion_builder.rb +140 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/unknown_address_concern.rb +30 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/unknown_province_concern.rb +38 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/unknown_zip_for_address_concern.rb +32 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/unmatched_field_concern.rb +84 -0
- data/app/models/atlas_engine/address_validation/validators/full_address/unsupported_script_result.rb +22 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/cache.rb +38 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/city/present.rb +36 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/country/exists.rb +34 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/country/valid_for_zip.rb +60 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/no_emojis.rb +38 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/no_html_tags.rb +39 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/no_url.rb +38 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/not_exceed_max_length.rb +34 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/not_exceed_max_token_count.rb +63 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/phone/valid.rb +41 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/predicate.rb +37 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/province/exists.rb +43 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/province/valid_for_country.rb +48 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/street/building_number_in_address1.rb +45 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/street/building_number_in_address1_or_address2.rb +43 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/street/present.rb +35 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/zip/present.rb +58 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/zip/valid_for_country.rb +45 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/zip/valid_for_province.rb +55 -0
- data/app/models/atlas_engine/address_validation/validators/predicates/zip/zip_base.rb +25 -0
- data/app/models/atlas_engine/address_validation/zip_truncator.rb +32 -0
- data/app/models/atlas_engine/application_record.rb +8 -0
- data/app/models/atlas_engine/coded_error.rb +18 -0
- data/app/models/atlas_engine/coded_errors.rb +17 -0
- data/app/models/atlas_engine/country_import.rb +44 -0
- data/app/models/atlas_engine/country_profile.rb +270 -0
- data/app/models/atlas_engine/country_profile_ingestion_subset.rb +42 -0
- data/app/models/atlas_engine/country_profile_subset_base.rb +22 -0
- data/app/models/atlas_engine/country_profile_validation_subset.rb +48 -0
- data/app/models/atlas_engine/country_repository.rb +110 -0
- data/app/models/atlas_engine/elasticsearch/client.rb +116 -0
- data/app/models/atlas_engine/elasticsearch/client_interface.rb +89 -0
- data/app/models/atlas_engine/elasticsearch/repository.rb +246 -0
- data/app/models/atlas_engine/elasticsearch/repository_interface.rb +82 -0
- data/app/models/atlas_engine/elasticsearch/response.rb +20 -0
- data/app/models/atlas_engine/event.rb +12 -0
- data/app/models/atlas_engine/field_decompounder.rb +36 -0
- data/app/models/atlas_engine/index_configuration_factory.rb +188 -0
- data/app/models/atlas_engine/post_address.rb +114 -0
- data/app/models/atlas_engine/post_address_importer.rb +34 -0
- data/app/models/atlas_engine/services/service_helper.rb +21 -0
- data/app/models/atlas_engine/services/validation.rb +65 -0
- data/app/models/atlas_engine/services/validation_eligibility.rb +18 -0
- data/app/models/atlas_engine/street.rb +34 -0
- data/app/tasks/maintenance/atlas_engine/elasticsearch_index_create_task.rb +106 -0
- data/app/tasks/maintenance/atlas_engine/geo_json_import_task.rb +29 -0
- data/app/views/atlas_engine/connectivity/index.html.erb +50 -0
- data/app/views/atlas_engine/country_imports/index.html.erb +49 -0
- data/app/views/atlas_engine/country_imports/show.html.erb +73 -0
- data/app/views/layouts/atlas_engine/application.html.erb +15 -0
- data/config/initializers/1.ruby_patches.rb +18 -0
- data/config/initializers/sorbet.rb +5 -0
- data/config/initializers/worldwide.rb +5 -0
- data/config/locales/internal/en.yml +14 -0
- data/config/routes.rb +17 -0
- data/db/data/address_synonyms/index_configurations/default.yml +141 -0
- data/db/data/country_profiles/default.yml +23 -0
- data/db/data/transcriber.yml +760 -0
- data/db/data/validation_pipelines/es.yml +58 -0
- data/db/data/validation_pipelines/es_street.yml +58 -0
- data/db/data/validation_pipelines/local.yml +60 -0
- data/db/migrate/20230919173037_create_atlas_engine_post_addresses.rb +25 -0
- data/db/migrate/20231117142735_add_building_and_unit_ranges_column.rb +7 -0
- data/db/migrate/20231117143536_create_atlas_engine_country_imports.rb +11 -0
- data/db/migrate/20231117145844_create_atlas_engine_events_table.rb +13 -0
- data/db/migrate/20231123153554_add_unique_index_to_atlas_engine_post_addresses.rb +14 -0
- data/db/migrate/20231123154658_add_index_to_post_addresses_on_source_id_locale_country_code.rb +12 -0
- data/lib/atlas_engine/engine.rb +10 -0
- data/lib/atlas_engine/version.rb +6 -0
- data/lib/atlas_engine.rb +66 -0
- data/lib/tasks/atlas_engine/address_importer.rake +20 -0
- metadata +553 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3d590dd6d627aea5298889faf7dccb0ec3479277beb107750a9da288c6c8aefa
|
4
|
+
data.tar.gz: 349e59b38ed5e20ee84c0b27cd660b619e789ff5755aa80af26a4e04e55bce5f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b0bea20736bd75159f04ad10c7f2f0b0805b0d5425b7c43c7d2426bd249a61ed28b80ca9ca20bae0190b91b5999771e2a6c9cf2780a2dc9e8693bb0073118dd7
|
7
|
+
data.tar.gz: 32c0509404553da96ef197a6ff01ae5e82a433e09d8a36ee27a0ae1b1fe1abce1be3b07c17d85ae7b52ba3eaee76626252e6298c33cc7d9036050ede3866acd5
|
data/README.md
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
# Atlas Engine
|
2
|
+
|
3
|
+
This is a rails engine that is meant to provide end-to-end address validation for rails apps
|
4
|
+
|
5
|
+
## Local Setup
|
6
|
+
|
7
|
+
### In your rails app
|
8
|
+
|
9
|
+
#### Initial setup
|
10
|
+
Add the engine to your gemfile
|
11
|
+
```
|
12
|
+
gem "atlas_engine", git: "https://github.com/Shopify/atlas-engine"
|
13
|
+
```
|
14
|
+
|
15
|
+
Run the following commands to install the engine in your rails app
|
16
|
+
|
17
|
+
```
|
18
|
+
bundle lock
|
19
|
+
bin/rails generate atlas_engine:install
|
20
|
+
```
|
21
|
+
|
22
|
+
#### Updating to a newer version of the engine
|
23
|
+
|
24
|
+
Working with migrations
|
25
|
+
```
|
26
|
+
# Copy any migrations from the engine into your app
|
27
|
+
rails atlas_engine:install:migrations
|
28
|
+
|
29
|
+
# Perform the migrations in your app
|
30
|
+
rails db:migrate
|
31
|
+
```
|
32
|
+
|
33
|
+
### Developing in the engine
|
34
|
+
|
35
|
+
#### Setup Docker
|
36
|
+
|
37
|
+
```
|
38
|
+
brew install docker
|
39
|
+
brew install docker-compose
|
40
|
+
|
41
|
+
# to setup the docker daemon
|
42
|
+
brew install colima
|
43
|
+
|
44
|
+
# to start the docker daemon
|
45
|
+
colima start --cpu 4 --memory 8
|
46
|
+
colima ssh
|
47
|
+
sudo sysctl -w vm.max_map_count=262144
|
48
|
+
exit
|
49
|
+
|
50
|
+
```
|
51
|
+
|
52
|
+
Verify if docker is running: `docker info`
|
53
|
+
|
54
|
+
#### Setup Rails
|
55
|
+
|
56
|
+
```
|
57
|
+
bundle install
|
58
|
+
|
59
|
+
# If you get an ssl error with puma installation run
|
60
|
+
bundle config build.puma --with-pkg-config=$(brew --prefix openssl@3)/lib/pkgconfig
|
61
|
+
```
|
62
|
+
|
63
|
+
#### Setting up Elasticsearch, Mysql
|
64
|
+
|
65
|
+
```
|
66
|
+
bash setup
|
67
|
+
docker-compose up
|
68
|
+
|
69
|
+
# If you encounter an error getting docker credentials, remove or update the `credsStore`
|
70
|
+
key in your Docker configuration file:
|
71
|
+
|
72
|
+
# ~/.docker/config.json
|
73
|
+
"credsStore": "desktop", # remove this line
|
74
|
+
```
|
75
|
+
|
76
|
+
Connecting to Docker services
|
77
|
+
* for Mysql : `mysql --host=127.0.0.1 --user=user --password=changeme`
|
78
|
+
* for Elasticsearch : `http://localhost:9200`
|
79
|
+
|
80
|
+
_note: if you have updated any of the ports in your .env file then use those ports instead_
|
81
|
+
|
82
|
+
|
83
|
+
#### Setting up db
|
84
|
+
```
|
85
|
+
rails db:setup
|
86
|
+
```
|
87
|
+
|
88
|
+
#### Setting up maintenance tasks
|
89
|
+
After locally setting up Atlas Engine:
|
90
|
+
```
|
91
|
+
rails app:maintenance_tasks:install:migrations
|
92
|
+
rails db:migrate
|
93
|
+
```
|
94
|
+
|
95
|
+
## Using the App
|
96
|
+
|
97
|
+
### Infrastructure Requirements
|
98
|
+
The elasticsearch implementation depends on the ICU analysis plugin. Refer to the [Dockfile](./Dockfile) leveraged in local setup for plugin installation.
|
99
|
+
|
100
|
+
### Starting the App and Testing
|
101
|
+
* `bin/rails server` to start the server
|
102
|
+
* `bin/rails test` to run tests
|
103
|
+
|
104
|
+
### Running Sorbet
|
105
|
+
|
106
|
+
Generate rbi files for custom code
|
107
|
+
```
|
108
|
+
bin/tapioca dsl --app-root="test/dummy/"
|
109
|
+
```
|
110
|
+
|
111
|
+
Generate rbi files for gems
|
112
|
+
```
|
113
|
+
bin/tapioca gems
|
114
|
+
|
115
|
+
# or
|
116
|
+
|
117
|
+
bin/tapioca gems --all
|
118
|
+
```
|
119
|
+
|
120
|
+
Running a sorbet check
|
121
|
+
```
|
122
|
+
srb tc
|
123
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# # frozen_string_literal: true
|
4
|
+
|
5
|
+
# # Add your own tasks in files placed in lib/tasks ending in .rake,
|
6
|
+
# # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
7
|
+
|
8
|
+
# require_relative "config/application"
|
9
|
+
|
10
|
+
# Rails.application.load_tasks
|
11
|
+
|
12
|
+
# from generate plugin --mountable
|
13
|
+
require "bundler/setup"
|
14
|
+
|
15
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
16
|
+
load "rails/tasks/engine.rake"
|
17
|
+
|
18
|
+
load "rails/tasks/statistics.rake"
|
19
|
+
|
20
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module AtlasEngine
|
5
|
+
module HandlesBlob
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
class BlobNotFoundError < StandardError; end
|
9
|
+
|
10
|
+
included do
|
11
|
+
def storage_service
|
12
|
+
ActiveStorage::Blob.service
|
13
|
+
end
|
14
|
+
|
15
|
+
def blob_exists?(key)
|
16
|
+
storage_service.exist?(key)
|
17
|
+
end
|
18
|
+
|
19
|
+
def download(key, &block)
|
20
|
+
raise BlobNotFoundError unless blob_exists?(key)
|
21
|
+
|
22
|
+
storage_service.open(key, verify: false, &block)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module AtlasEngine
|
5
|
+
module HandlesInterruption
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
include LogHelper
|
8
|
+
include Kernel
|
9
|
+
|
10
|
+
included do
|
11
|
+
def exit_if_interrupted!(import)
|
12
|
+
import_state = Rails.cache.fetch("country_import:#{import.id}:state", expires_in: 5.seconds) do
|
13
|
+
import.reload.state
|
14
|
+
end
|
15
|
+
|
16
|
+
return unless import_state == "failed"
|
17
|
+
|
18
|
+
raise CountryImport::InterruptionError, "Import interrupted at #{Time.current.utc.to_fs}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module AtlasEngine
|
5
|
+
class ConnectivityController < ApplicationController
|
6
|
+
def initialize
|
7
|
+
super
|
8
|
+
@repository = AtlasEngine::Elasticsearch::Repository.new(
|
9
|
+
index_base_name: "",
|
10
|
+
index_settings: {},
|
11
|
+
index_mappings: {},
|
12
|
+
mapper_callable: nil,
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def index
|
17
|
+
@indices = @repository.indices
|
18
|
+
@post_addresses = AtlasEngine::PostAddress.limit(10)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module AtlasEngine
|
5
|
+
class CountryImportsController < ApplicationController
|
6
|
+
extend T::Sig
|
7
|
+
|
8
|
+
before_action :set_page, only: [:index]
|
9
|
+
before_action :set_country_import, only: [:interrupt, :show]
|
10
|
+
|
11
|
+
include LogHelper
|
12
|
+
layout "application"
|
13
|
+
|
14
|
+
sig { void }
|
15
|
+
def initialize
|
16
|
+
super
|
17
|
+
@page = T.let(0, Integer)
|
18
|
+
@country_import = T.let(T.unsafe(nil), T.nilable(CountryImport), checked: false)
|
19
|
+
@country_imports = T.let(T.unsafe(nil), ActiveRecord::Relation, checked: false)
|
20
|
+
@events = T.let(T.unsafe(nil), ActiveRecord::Relation, checked: false)
|
21
|
+
end
|
22
|
+
|
23
|
+
# GET /country_imports
|
24
|
+
sig { void }
|
25
|
+
def index
|
26
|
+
@country_imports = CountryImport.order(id: :desc)
|
27
|
+
.offset(CountryImport::PAGE_SIZE * @page)
|
28
|
+
.limit(CountryImport::PAGE_SIZE)
|
29
|
+
end
|
30
|
+
|
31
|
+
sig { void }
|
32
|
+
def show
|
33
|
+
@events = Event.where(country_import: @country_import).order(id: :desc).limit(1000)
|
34
|
+
end
|
35
|
+
|
36
|
+
# GET /country_imports/1/interrupt
|
37
|
+
sig { void }
|
38
|
+
def interrupt
|
39
|
+
T.must(@country_import).interrupt!
|
40
|
+
|
41
|
+
log_info("Country import manually interrupted", { country_import_id: T.must(@country_import).id })
|
42
|
+
redirect_back_or_to(
|
43
|
+
country_imports_url,
|
44
|
+
notice: "Country import manually interrupted. Wait a few minutes for ongoing jobs to stop.",
|
45
|
+
)
|
46
|
+
rescue => e
|
47
|
+
log_error(
|
48
|
+
"Country import manual interruption failed with #{e.class} - #{e.message}; stack trace #{e.backtrace.inspect}",
|
49
|
+
{ country_import_id: T.must(@country_import).id },
|
50
|
+
)
|
51
|
+
redirect_back_or_to(
|
52
|
+
country_imports_url,
|
53
|
+
alert: "Interruption of country import failed with #{e.class}, #{e.message}",
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
sig { returns(T.nilable(CountryImport)) }
|
60
|
+
def set_country_import
|
61
|
+
@country_import = begin
|
62
|
+
CountryImport.find(params[:id])
|
63
|
+
rescue
|
64
|
+
nil
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
sig { returns(Integer) }
|
69
|
+
def set_page
|
70
|
+
@page = params.fetch(:page, 0).to_i
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module AtlasEngine
|
5
|
+
class GraphqlController < ApplicationController
|
6
|
+
# If accessing from outside this domain, nullify the session
|
7
|
+
# This allows for outside API access while preventing CSRF attacks,
|
8
|
+
# but you'll have to authenticate your user separately
|
9
|
+
protect_from_forgery with: :null_session, prepend: true
|
10
|
+
|
11
|
+
def execute
|
12
|
+
variables = prepare_variables(params[:variables])
|
13
|
+
query = params[:query]
|
14
|
+
operation_name = params[:operationName]
|
15
|
+
context = {
|
16
|
+
# Query context goes here, for example:
|
17
|
+
# current_user: current_user,
|
18
|
+
}
|
19
|
+
result = Schema.execute(query, variables: variables, context: context, operation_name: operation_name)
|
20
|
+
render(json: result)
|
21
|
+
rescue StandardError => e
|
22
|
+
raise e unless Rails.env.development?
|
23
|
+
|
24
|
+
handle_error_in_development(e)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# Handle variables in form data, JSON body, or a blank value
|
30
|
+
def prepare_variables(variables_param)
|
31
|
+
case variables_param
|
32
|
+
when String
|
33
|
+
if variables_param.present?
|
34
|
+
JSON.parse(variables_param) || {}
|
35
|
+
else
|
36
|
+
{}
|
37
|
+
end
|
38
|
+
when Hash
|
39
|
+
variables_param
|
40
|
+
when ActionController::Parameters
|
41
|
+
variables_param.to_unsafe_hash # GraphQL-Ruby will validate name and type of incoming variables.
|
42
|
+
when nil
|
43
|
+
{}
|
44
|
+
else
|
45
|
+
raise ArgumentError, "Unexpected parameter: #{variables_param}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def handle_error_in_development(e)
|
50
|
+
logger.error(e.message)
|
51
|
+
logger.error(e.backtrace.join("\n"))
|
52
|
+
|
53
|
+
render(
|
54
|
+
json: { errors: [{ message: e.message, backtrace: e.backtrace }], data: {} },
|
55
|
+
status: :internal_server_error,
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/app/countries/atlas_engine/at/address_importer/corrections/open_address/city_corrector.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module AtlasEngine
|
5
|
+
module At
|
6
|
+
module AddressImporter
|
7
|
+
module Corrections
|
8
|
+
module OpenAddress
|
9
|
+
class CityCorrector
|
10
|
+
class << self
|
11
|
+
extend T::Sig
|
12
|
+
|
13
|
+
sig { params(address: Hash).void }
|
14
|
+
def apply(address)
|
15
|
+
address[:city] = ["Wien"] if address[:zip].starts_with?("1")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
id: AT
|
2
|
+
ingestion:
|
3
|
+
correctors:
|
4
|
+
open_address:
|
5
|
+
- AtlasEngine::At::AddressImporter::Corrections::OpenAddress::CityCorrector
|
6
|
+
settings:
|
7
|
+
min_zip_edge_ngram: "1"
|
8
|
+
max_zip_edge_ngram: "4"
|
9
|
+
data_mapper: AtlasEngine::AddressValidation::Es::DataMappers::DecompoundingDataMapper
|
10
|
+
validation:
|
11
|
+
enabled: true
|
12
|
+
default_matching_strategy: es
|
13
|
+
has_provinces: true
|
14
|
+
address_parser: AtlasEngine::At::ValidationTranscriber::AddressParser
|
15
|
+
normalized_components:
|
16
|
+
- region2
|
17
|
+
- region3
|
18
|
+
- region4
|
19
|
+
- city_aliases.alias
|
20
|
+
- suburb
|
21
|
+
- street_decompounded
|
22
|
+
decompounding_patterns:
|
23
|
+
street:
|
24
|
+
- (?<name>\w+)(?<suffix>allee|gasse|kai|lande|pfad|platz|pl|ring|strasse|str|weg|zeile)(?:\b)
|
@@ -0,0 +1,63 @@
|
|
1
|
+
mappings:
|
2
|
+
properties:
|
3
|
+
street:
|
4
|
+
analyzer: street_indexing_analyzer
|
5
|
+
search_analyzer: street_decompounding_analyzer
|
6
|
+
street_stripped:
|
7
|
+
analyzer: street_indexing_analyzer
|
8
|
+
search_analyzer: street_decompounding_analyzer
|
9
|
+
street_decompounded:
|
10
|
+
type: text
|
11
|
+
analyzer: text_analyzer
|
12
|
+
fields:
|
13
|
+
keyword:
|
14
|
+
type: keyword
|
15
|
+
settings:
|
16
|
+
index:
|
17
|
+
analysis:
|
18
|
+
analyzer:
|
19
|
+
text_analyzer:
|
20
|
+
filter:
|
21
|
+
- lowercase
|
22
|
+
- german_normalization
|
23
|
+
- icu_folding
|
24
|
+
- strip_special_characters
|
25
|
+
street_indexing_analyzer:
|
26
|
+
tokenizer: standard
|
27
|
+
filter:
|
28
|
+
- lowercase
|
29
|
+
- german_normalization
|
30
|
+
- icu_folding
|
31
|
+
- strip_special_characters
|
32
|
+
- street_suffix_decompounder
|
33
|
+
street_decompounding_analyzer:
|
34
|
+
tokenizer: standard
|
35
|
+
filter:
|
36
|
+
- lowercase
|
37
|
+
- german_normalization
|
38
|
+
- icu_folding
|
39
|
+
- strip_special_characters
|
40
|
+
- street_suffix_decompounder
|
41
|
+
- street_synonyms
|
42
|
+
street_analyzer:
|
43
|
+
filter:
|
44
|
+
- lowercase
|
45
|
+
- german_normalization
|
46
|
+
- icu_folding
|
47
|
+
- strip_special_characters
|
48
|
+
- street_synonyms
|
49
|
+
city_analyzer:
|
50
|
+
filter:
|
51
|
+
- lowercase
|
52
|
+
- german_normalization
|
53
|
+
- icu_folding
|
54
|
+
- strip_special_characters
|
55
|
+
- city_synonyms
|
56
|
+
filter:
|
57
|
+
street_suffix_decompounder:
|
58
|
+
type: pattern_capture
|
59
|
+
preserve_original: "false"
|
60
|
+
patterns:
|
61
|
+
<% country_profile.decompounding_patterns(:street).each do |pattern| %>
|
62
|
+
- <%= pattern %>
|
63
|
+
<% end %>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module AtlasEngine
|
5
|
+
module At
|
6
|
+
module ValidationTranscriber
|
7
|
+
class AddressParser < AtlasEngine::ValidationTranscriber::AddressParserBase
|
8
|
+
private
|
9
|
+
|
10
|
+
STREET = "(?<street>.+?)"
|
11
|
+
NUMBERED_STREET = "(?<street>.+\s+[0-9]+)"
|
12
|
+
BUILDING_NUM = "(?<building_num>[0-9]+[[:alpha:]]*)"
|
13
|
+
UNIT_NUM = "(?<unit_num>.+)"
|
14
|
+
|
15
|
+
sig { returns(T::Array[Regexp]) }
|
16
|
+
def country_regex_formats
|
17
|
+
@country_regex_formats ||= [
|
18
|
+
%r{^#{STREET},?\s+#{BUILDING_NUM}([\s,-/]+#{UNIT_NUM})?$},
|
19
|
+
%r{^#{NUMBERED_STREET},?\s+#{BUILDING_NUM}([\s,-/]+#{UNIT_NUM})?$},
|
20
|
+
]
|
21
|
+
end
|
22
|
+
|
23
|
+
sig { override.params(address_line: String).returns(T::Array[T.nilable(String)]) }
|
24
|
+
def extract_po_box(address_line)
|
25
|
+
[address_line, nil]
|
26
|
+
end
|
27
|
+
|
28
|
+
# Return true if something's obviously wrong with this regex match
|
29
|
+
sig do
|
30
|
+
override.params(
|
31
|
+
captures: T::Hash[Symbol, T.nilable(String)],
|
32
|
+
address: AddressValidation::TAddress,
|
33
|
+
).returns(T::Boolean)
|
34
|
+
end
|
35
|
+
def ridiculous?(captures, address)
|
36
|
+
street = captures[:street]&.downcase
|
37
|
+
|
38
|
+
if street.present?
|
39
|
+
true unless address.address1&.upcase&.include?(street.upcase) ||
|
40
|
+
address.address2&.upcase&.include?(street.upcase)
|
41
|
+
end
|
42
|
+
|
43
|
+
false
|
44
|
+
end
|
45
|
+
|
46
|
+
sig { override.params(token: T.nilable(String)).returns(T::Boolean) }
|
47
|
+
def po_box?(token)
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
sig { override.params(token: T.nilable(String)).returns(T::Boolean) }
|
52
|
+
def street_suffix?(token)
|
53
|
+
false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module AtlasEngine
|
5
|
+
module Au
|
6
|
+
module AddressImporter
|
7
|
+
module OpenAddress
|
8
|
+
class Filter
|
9
|
+
extend T::Sig
|
10
|
+
include AtlasEngine::AddressImporter::OpenAddress::Filter
|
11
|
+
|
12
|
+
def initialize(country_import:); end
|
13
|
+
|
14
|
+
sig { override.params(feature: AtlasEngine::AddressImporter::OpenAddress::Feature).returns(T::Boolean) }
|
15
|
+
def filter(feature)
|
16
|
+
# Discard features from the overseas territories, like Cocos, Christmas Island, etc.
|
17
|
+
# See: https://github.com/Shopify/worldwide/blob/c76c344/db/data/world.yml#L304-L308
|
18
|
+
return false if feature["region"] == "OT"
|
19
|
+
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module AtlasEngine
|
5
|
+
module Au
|
6
|
+
module AddressImporter
|
7
|
+
module OpenAddress
|
8
|
+
class Mapper < AtlasEngine::AddressImporter::OpenAddress::DefaultMapper
|
9
|
+
sig do
|
10
|
+
params(feature: AtlasEngine::AddressImporter::OpenAddress::Feature).returns(T::Hash[Symbol, T.untyped])
|
11
|
+
end
|
12
|
+
def map(feature)
|
13
|
+
region, city, street, number, unit, postcode = feature["properties"].values_at(
|
14
|
+
"region",
|
15
|
+
"city",
|
16
|
+
"street",
|
17
|
+
"number",
|
18
|
+
"unit",
|
19
|
+
"postcode",
|
20
|
+
)
|
21
|
+
{
|
22
|
+
source_id: openaddress_source_id(feature),
|
23
|
+
locale: @locale,
|
24
|
+
country_code: "AU",
|
25
|
+
province_code: province_from_code(region),
|
26
|
+
# Omitted: region1..4
|
27
|
+
city: [city.titleize],
|
28
|
+
suburb: nil, # District field seems to always be empty and not useful
|
29
|
+
zip: postcode,
|
30
|
+
street: street.titleize,
|
31
|
+
# NOTE: unit seems to be 'UNIT|SUITE|CARSPACE|SHOP|VILLA N'. Do we strip text before the number?
|
32
|
+
building_and_unit_ranges: housenumber_and_unit(number, unit),
|
33
|
+
latitude: geometry(feature)&.at(1),
|
34
|
+
longitude: geometry(feature)&.at(0),
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
id: AU
|
2
|
+
ingestion:
|
3
|
+
settings:
|
4
|
+
min_zip_edge_ngram: "1"
|
5
|
+
max_zip_edge_ngram: "4"
|
6
|
+
open_address:
|
7
|
+
feature_mapper: AtlasEngine::Au::AddressImporter::OpenAddress::Mapper
|
8
|
+
validation:
|
9
|
+
address_parser: AtlasEngine::Au::ValidationTranscriber::AddressParser
|
10
|
+
enabled: true
|
11
|
+
default_matching_strategy: es
|
12
|
+
open_address:
|
13
|
+
filter: AtlasEngine::Au::AddressImporter::OpenAddress::Filter
|