atlas_engine 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (298) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +123 -0
  3. data/Rakefile +20 -0
  4. data/app/assets/config/atlas_engine_manifest.js +3 -0
  5. data/app/assets/stylesheets/atlas_engine/application.css +15 -0
  6. data/app/concerns/atlas_engine/handles_blob.rb +26 -0
  7. data/app/concerns/atlas_engine/handles_interruption.rb +22 -0
  8. data/app/controllers/atlas_engine/application_controller.rb +7 -0
  9. data/app/controllers/atlas_engine/connectivity_controller.rb +21 -0
  10. data/app/controllers/atlas_engine/country_imports_controller.rb +73 -0
  11. data/app/controllers/atlas_engine/graphql_controller.rb +59 -0
  12. data/app/countries/atlas_engine/ar/country_profile.yml +9 -0
  13. data/app/countries/atlas_engine/at/address_importer/corrections/open_address/city_corrector.rb +23 -0
  14. data/app/countries/atlas_engine/at/country_profile.yml +24 -0
  15. data/app/countries/atlas_engine/at/index_configuration.yml +63 -0
  16. data/app/countries/atlas_engine/at/synonyms.yml +6 -0
  17. data/app/countries/atlas_engine/at/validation_transcriber/address_parser.rb +58 -0
  18. data/app/countries/atlas_engine/au/address_importer/open_address/filter.rb +26 -0
  19. data/app/countries/atlas_engine/au/address_importer/open_address/mapper.rb +41 -0
  20. data/app/countries/atlas_engine/au/country_profile.yml +13 -0
  21. data/app/countries/atlas_engine/au/synonyms.yml +209 -0
  22. data/app/countries/atlas_engine/au/validation_transcriber/address_parser.rb +121 -0
  23. data/app/countries/atlas_engine/be/country_profile.yml +12 -0
  24. data/app/countries/atlas_engine/bm/address_importer/corrections/open_address/city_alias_corrector.rb +38 -0
  25. data/app/countries/atlas_engine/bm/address_importer/open_address/mapper.rb +40 -0
  26. data/app/countries/atlas_engine/bm/country_profile.yml +12 -0
  27. data/app/countries/atlas_engine/br/country_profile.yml +4 -0
  28. data/app/countries/atlas_engine/ca/country_profile.yml +7 -0
  29. data/app/countries/atlas_engine/ca/synonyms.yml +1615 -0
  30. data/app/countries/atlas_engine/ch/address_importer/corrections/open_address/city_corrector.rb +29 -0
  31. data/app/countries/atlas_engine/ch/address_importer/corrections/open_address/locale_corrector.rb +74 -0
  32. data/app/countries/atlas_engine/ch/address_importer/open_address/mapper.rb +40 -0
  33. data/app/countries/atlas_engine/ch/country_profile.yml +15 -0
  34. data/app/countries/atlas_engine/ch/locales/de/country_profile.yml +15 -0
  35. data/app/countries/atlas_engine/ch/locales/de/index_configuration.yml +63 -0
  36. data/app/countries/atlas_engine/ch/locales/de/synonyms.yml +7 -0
  37. data/app/countries/atlas_engine/ch/locales/fr/synonyms.yml +21 -0
  38. data/app/countries/atlas_engine/cz/country_profile.yml +6 -0
  39. data/app/countries/atlas_engine/de/country_profile.yml +19 -0
  40. data/app/countries/atlas_engine/de/index_configuration.yml +64 -0
  41. data/app/countries/atlas_engine/de/synonyms.yml +2 -0
  42. data/app/countries/atlas_engine/de/validation_transcriber/address_parser.rb +19 -0
  43. data/app/countries/atlas_engine/dk/country_profile.yml +6 -0
  44. data/app/countries/atlas_engine/dk/synonyms.yml +3 -0
  45. data/app/countries/atlas_engine/dk/validation_transcriber/address_parser.rb +21 -0
  46. data/app/countries/atlas_engine/fo/country_profile.yml +5 -0
  47. data/app/countries/atlas_engine/fr/address_importer/corrections/open_address/city_corrector.rb +28 -0
  48. data/app/countries/atlas_engine/fr/country_profile.yml +13 -0
  49. data/app/countries/atlas_engine/fr/synonyms.yml +21 -0
  50. data/app/countries/atlas_engine/fr/validation_transcriber/address_parser.rb +34 -0
  51. data/app/countries/atlas_engine/gb/address_validation/es/query_builder.rb +98 -0
  52. data/app/countries/atlas_engine/gb/country_profile.yml +10 -0
  53. data/app/countries/atlas_engine/gb/validation_transcriber/full_address_parser.rb +164 -0
  54. data/app/countries/atlas_engine/gb/validation_transcriber/parsed_address.rb +120 -0
  55. data/app/countries/atlas_engine/gg/address_validation/validators/full_address/restrictions/unsupported_city.rb +39 -0
  56. data/app/countries/atlas_engine/gg/country_profile.yml +7 -0
  57. data/app/countries/atlas_engine/ie/country_profile.yml +3 -0
  58. data/app/countries/atlas_engine/it/address_importer/corrections/open_address/city_corrector.rb +27 -0
  59. data/app/countries/atlas_engine/it/address_importer/corrections/open_address/province_corrector.rb +29 -0
  60. data/app/countries/atlas_engine/it/address_importer/open_address/mapper.rb +42 -0
  61. data/app/countries/atlas_engine/it/country_profile.yml +11 -0
  62. data/app/countries/atlas_engine/jp/address_validation/es/data_mapper.rb +63 -0
  63. data/app/countries/atlas_engine/jp/country_profile.yml +6 -0
  64. data/app/countries/atlas_engine/kr/address_importer/open_address/mapper.rb +41 -0
  65. data/app/countries/atlas_engine/kr/country_profile.yml +11 -0
  66. data/app/countries/atlas_engine/li/address_importer/corrections/open_address/city_corrector.rb +25 -0
  67. data/app/countries/atlas_engine/li/country_profile.yml +21 -0
  68. data/app/countries/atlas_engine/li/index_configuration.yml +63 -0
  69. data/app/countries/atlas_engine/li/synonyms.yml +6 -0
  70. data/app/countries/atlas_engine/lt/country_profile.yml +6 -0
  71. data/app/countries/atlas_engine/lt/synonyms.yml +7 -0
  72. data/app/countries/atlas_engine/lt/validation_transcriber/address_parser.rb +24 -0
  73. data/app/countries/atlas_engine/lu/address_importer/corrections/open_address/locale_corrector.rb +54 -0
  74. data/app/countries/atlas_engine/lu/country_profile.yml +12 -0
  75. data/app/countries/atlas_engine/nl/address_importer/corrections/open_address/city_corrector.rb +25 -0
  76. data/app/countries/atlas_engine/nl/country_profile.yml +18 -0
  77. data/app/countries/atlas_engine/nl/index_configuration.yml +52 -0
  78. data/app/countries/atlas_engine/nl/synonyms.yml +92 -0
  79. data/app/countries/atlas_engine/nl/validation_transcriber/address_parser.rb +85 -0
  80. data/app/countries/atlas_engine/no/country_profile.yml +5 -0
  81. data/app/countries/atlas_engine/nz/country_profile.yml +3 -0
  82. data/app/countries/atlas_engine/pl/country_profile.yml +5 -0
  83. data/app/countries/atlas_engine/pl/validation_transcriber/address_parser.rb +19 -0
  84. data/app/countries/atlas_engine/pt/address_importer/corrections/open_address/city_corrector.rb +32 -0
  85. data/app/countries/atlas_engine/pt/address_importer/open_address/mapper.rb +39 -0
  86. data/app/countries/atlas_engine/pt/country_profile.yml +10 -0
  87. data/app/countries/atlas_engine/pt/synonyms.yml +7 -0
  88. data/app/countries/atlas_engine/sa/country_profile.yml +10 -0
  89. data/app/countries/atlas_engine/se/country_profile.yml +5 -0
  90. data/app/countries/atlas_engine/tt/address_importer/open_address/mapper.rb +38 -0
  91. data/app/countries/atlas_engine/tt/country_profile.yml +7 -0
  92. data/app/countries/atlas_engine/us/country_profile.yml +12 -0
  93. data/app/countries/atlas_engine/us/synonyms.yml +350 -0
  94. data/app/graphql/atlas_engine/errors/locale_unsupported_error.rb +17 -0
  95. data/app/graphql/atlas_engine/schema.graphql +1293 -0
  96. data/app/graphql/atlas_engine/schema.rb +23 -0
  97. data/app/graphql/atlas_engine/types/address_validation/address_input.rb +51 -0
  98. data/app/graphql/atlas_engine/types/address_validation/concern_type.rb +20 -0
  99. data/app/graphql/atlas_engine/types/address_validation/enums/concern_enum.rb +15 -0
  100. data/app/graphql/atlas_engine/types/address_validation/field_type.rb +15 -0
  101. data/app/graphql/atlas_engine/types/address_validation/suggestion_type.rb +21 -0
  102. data/app/graphql/atlas_engine/types/base_argument.rb +9 -0
  103. data/app/graphql/atlas_engine/types/base_enum.rb +9 -0
  104. data/app/graphql/atlas_engine/types/base_field.rb +10 -0
  105. data/app/graphql/atlas_engine/types/base_input_object.rb +9 -0
  106. data/app/graphql/atlas_engine/types/base_interface.rb +10 -0
  107. data/app/graphql/atlas_engine/types/base_object.rb +9 -0
  108. data/app/graphql/atlas_engine/types/base_scalar.rb +9 -0
  109. data/app/graphql/atlas_engine/types/base_union.rb +9 -0
  110. data/app/graphql/atlas_engine/types/matching_strategy_type.rb +12 -0
  111. data/app/graphql/atlas_engine/types/mutation_type.rb +9 -0
  112. data/app/graphql/atlas_engine/types/query_type.rb +61 -0
  113. data/app/graphql/atlas_engine/types/validation_supported_country.rb +12 -0
  114. data/app/graphql/atlas_engine/types/validation_type.rb +22 -0
  115. data/app/helpers/atlas_engine/address_importer/import_log_helper.rb +66 -0
  116. data/app/helpers/atlas_engine/application_helper.rb +7 -0
  117. data/app/helpers/atlas_engine/locale_format_helper.rb +40 -0
  118. data/app/helpers/atlas_engine/log_base.rb +32 -0
  119. data/app/helpers/atlas_engine/log_helper.rb +24 -0
  120. data/app/helpers/atlas_engine/metrics_helper.rb +25 -0
  121. data/app/jobs/atlas_engine/address_importer/clear_records_job.rb +39 -0
  122. data/app/jobs/atlas_engine/address_importer/open_address/geo_json_import_job.rb +212 -0
  123. data/app/jobs/atlas_engine/address_importer/open_address/geo_json_import_launcher_job.rb +67 -0
  124. data/app/jobs/atlas_engine/address_importer/open_address/prepares_geo_json_file.rb +41 -0
  125. data/app/jobs/atlas_engine/address_importer/resumable_import_job.rb +49 -0
  126. data/app/jobs/atlas_engine/address_importer/street_backfill_job.rb +63 -0
  127. data/app/jobs/atlas_engine/application_job.rb +10 -0
  128. data/app/jobs/atlas_engine/concerns/address_importer/handles_errors.rb +43 -0
  129. data/app/lib/atlas_engine/concern_formatter.rb +40 -0
  130. data/app/lib/atlas_engine/restrictions/base.rb +20 -0
  131. data/app/lib/atlas_engine/restrictions/unsupported_script.rb +31 -0
  132. data/app/lib/atlas_engine/validation_transcriber/address_parser_base.rb +201 -0
  133. data/app/lib/atlas_engine/validation_transcriber/address_parser_factory.rb +27 -0
  134. data/app/lib/atlas_engine/validation_transcriber/address_parser_north_america.rb +39 -0
  135. data/app/lib/atlas_engine/validation_transcriber/address_parser_oceanic.rb +17 -0
  136. data/app/lib/atlas_engine/validation_transcriber/address_parser_preprocessor.rb +132 -0
  137. data/app/lib/atlas_engine/validation_transcriber/address_parsing_helper.rb +38 -0
  138. data/app/lib/atlas_engine/validation_transcriber/address_parsings.rb +54 -0
  139. data/app/lib/atlas_engine/validation_transcriber/constants.rb +50 -0
  140. data/app/lib/atlas_engine/validation_transcriber/english_street_parser.rb +59 -0
  141. data/app/lib/atlas_engine/validation_transcriber/formatter.rb +46 -0
  142. data/app/lib/atlas_engine/validation_transcriber/french_street_parser.rb +50 -0
  143. data/app/lib/atlas_engine/validation_transcriber/province_code_normalizer.rb +45 -0
  144. data/app/lib/atlas_engine/validation_transcriber/street_parser.rb +18 -0
  145. data/app/lib/atlas_engine/validation_transcriber/zip_normalizer.rb +23 -0
  146. data/app/mailers/atlas_engine/application_mailer.rb +9 -0
  147. data/app/models/atlas_engine/address_importer/corrections/corrector.rb +33 -0
  148. data/app/models/atlas_engine/address_importer/import_events_notifier/base.rb +35 -0
  149. data/app/models/atlas_engine/address_importer/import_events_notifier/notifier.rb +26 -0
  150. data/app/models/atlas_engine/address_importer/open_address/default_mapper.rb +46 -0
  151. data/app/models/atlas_engine/address_importer/open_address/feature_helper.rb +110 -0
  152. data/app/models/atlas_engine/address_importer/open_address/filter.rb +17 -0
  153. data/app/models/atlas_engine/address_importer/open_address/loader.rb +27 -0
  154. data/app/models/atlas_engine/address_importer/open_address/transformer.rb +39 -0
  155. data/app/models/atlas_engine/address_importer/open_address.rb +10 -0
  156. data/app/models/atlas_engine/address_importer/validation/base_validator.rb +86 -0
  157. data/app/models/atlas_engine/address_importer/validation/default_validator.rb +27 -0
  158. data/app/models/atlas_engine/address_importer/validation/field_validations/city.rb +47 -0
  159. data/app/models/atlas_engine/address_importer/validation/field_validations/interface.rb +29 -0
  160. data/app/models/atlas_engine/address_importer/validation/field_validations/province.rb +73 -0
  161. data/app/models/atlas_engine/address_importer/validation/field_validations/zip.rb +84 -0
  162. data/app/models/atlas_engine/address_importer/validation/validator.rb +17 -0
  163. data/app/models/atlas_engine/address_importer/validation/wrapper.rb +70 -0
  164. data/app/models/atlas_engine/address_number.rb +36 -0
  165. data/app/models/atlas_engine/address_number_range.rb +200 -0
  166. data/app/models/atlas_engine/address_validation/abstract_address.rb +49 -0
  167. data/app/models/atlas_engine/address_validation/address.rb +47 -0
  168. data/app/models/atlas_engine/address_validation/candidate.rb +109 -0
  169. data/app/models/atlas_engine/address_validation/candidate_tuple.rb +15 -0
  170. data/app/models/atlas_engine/address_validation/concern.rb +74 -0
  171. data/app/models/atlas_engine/address_validation/concern_producer.rb +19 -0
  172. data/app/models/atlas_engine/address_validation/concern_queue.rb +20 -0
  173. data/app/models/atlas_engine/address_validation/concern_record.rb +122 -0
  174. data/app/models/atlas_engine/address_validation/datastore_base.rb +27 -0
  175. data/app/models/atlas_engine/address_validation/errors.rb +13 -0
  176. data/app/models/atlas_engine/address_validation/es/candidate_selector.rb +70 -0
  177. data/app/models/atlas_engine/address_validation/es/data_mappers/decompounding_data_mapper.rb +39 -0
  178. data/app/models/atlas_engine/address_validation/es/data_mappers/default_data_mapper.rb +110 -0
  179. data/app/models/atlas_engine/address_validation/es/datastore.rb +229 -0
  180. data/app/models/atlas_engine/address_validation/es/default_query_builder.rb +30 -0
  181. data/app/models/atlas_engine/address_validation/es/query_builder.rb +160 -0
  182. data/app/models/atlas_engine/address_validation/es/term_vectors.rb +78 -0
  183. data/app/models/atlas_engine/address_validation/es/validators/full_address.rb +123 -0
  184. data/app/models/atlas_engine/address_validation/es/validators/full_address_street.rb +18 -0
  185. data/app/models/atlas_engine/address_validation/es/validators/restriction_evaluator.rb +37 -0
  186. data/app/models/atlas_engine/address_validation/field.rb +30 -0
  187. data/app/models/atlas_engine/address_validation/full_address_validator_base.rb +27 -0
  188. data/app/models/atlas_engine/address_validation/log_emitter.rb +66 -0
  189. data/app/models/atlas_engine/address_validation/matching_strategies.rb +16 -0
  190. data/app/models/atlas_engine/address_validation/normalizer.rb +38 -0
  191. data/app/models/atlas_engine/address_validation/predicate_pipeline.rb +80 -0
  192. data/app/models/atlas_engine/address_validation/request.rb +12 -0
  193. data/app/models/atlas_engine/address_validation/result.rb +154 -0
  194. data/app/models/atlas_engine/address_validation/runs_validation.rb +16 -0
  195. data/app/models/atlas_engine/address_validation/session.rb +47 -0
  196. data/app/models/atlas_engine/address_validation/statsd_emitter.rb +72 -0
  197. data/app/models/atlas_engine/address_validation/strategies.rb +10 -0
  198. data/app/models/atlas_engine/address_validation/suggestion.rb +97 -0
  199. data/app/models/atlas_engine/address_validation/token/comparator.rb +44 -0
  200. data/app/models/atlas_engine/address_validation/token/comparison.rb +76 -0
  201. data/app/models/atlas_engine/address_validation/token/sequence/comparator.rb +158 -0
  202. data/app/models/atlas_engine/address_validation/token/sequence/comparison.rb +166 -0
  203. data/app/models/atlas_engine/address_validation/token/sequence.rb +147 -0
  204. data/app/models/atlas_engine/address_validation/token/synonyms.rb +77 -0
  205. data/app/models/atlas_engine/address_validation/token.rb +113 -0
  206. data/app/models/atlas_engine/address_validation/validator.rb +147 -0
  207. data/app/models/atlas_engine/address_validation/validators/full_address/address_comparison.rb +97 -0
  208. data/app/models/atlas_engine/address_validation/validators/full_address/candidate_result.rb +164 -0
  209. data/app/models/atlas_engine/address_validation/validators/full_address/candidate_result_base.rb +46 -0
  210. data/app/models/atlas_engine/address_validation/validators/full_address/comparison_helper.rb +135 -0
  211. data/app/models/atlas_engine/address_validation/validators/full_address/components_to_validate.rb +88 -0
  212. data/app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb +127 -0
  213. data/app/models/atlas_engine/address_validation/validators/full_address/exclusions/exclusion_base.rb +23 -0
  214. data/app/models/atlas_engine/address_validation/validators/full_address/invalid_zip_concern_builder.rb +42 -0
  215. data/app/models/atlas_engine/address_validation/validators/full_address/invalid_zip_for_country_concern.rb +37 -0
  216. data/app/models/atlas_engine/address_validation/validators/full_address/invalid_zip_for_province_concern.rb +37 -0
  217. data/app/models/atlas_engine/address_validation/validators/full_address/no_candidate_result.rb +26 -0
  218. data/app/models/atlas_engine/address_validation/validators/full_address/number_comparison.rb +31 -0
  219. data/app/models/atlas_engine/address_validation/validators/full_address/postal_code_matcher.rb +60 -0
  220. data/app/models/atlas_engine/address_validation/validators/full_address/result_updater.rb +42 -0
  221. data/app/models/atlas_engine/address_validation/validators/full_address/suggestion_builder.rb +140 -0
  222. data/app/models/atlas_engine/address_validation/validators/full_address/unknown_address_concern.rb +30 -0
  223. data/app/models/atlas_engine/address_validation/validators/full_address/unknown_province_concern.rb +38 -0
  224. data/app/models/atlas_engine/address_validation/validators/full_address/unknown_zip_for_address_concern.rb +32 -0
  225. data/app/models/atlas_engine/address_validation/validators/full_address/unmatched_field_concern.rb +84 -0
  226. data/app/models/atlas_engine/address_validation/validators/full_address/unsupported_script_result.rb +22 -0
  227. data/app/models/atlas_engine/address_validation/validators/predicates/cache.rb +38 -0
  228. data/app/models/atlas_engine/address_validation/validators/predicates/city/present.rb +36 -0
  229. data/app/models/atlas_engine/address_validation/validators/predicates/country/exists.rb +34 -0
  230. data/app/models/atlas_engine/address_validation/validators/predicates/country/valid_for_zip.rb +60 -0
  231. data/app/models/atlas_engine/address_validation/validators/predicates/no_emojis.rb +38 -0
  232. data/app/models/atlas_engine/address_validation/validators/predicates/no_html_tags.rb +39 -0
  233. data/app/models/atlas_engine/address_validation/validators/predicates/no_url.rb +38 -0
  234. data/app/models/atlas_engine/address_validation/validators/predicates/not_exceed_max_length.rb +34 -0
  235. data/app/models/atlas_engine/address_validation/validators/predicates/not_exceed_max_token_count.rb +63 -0
  236. data/app/models/atlas_engine/address_validation/validators/predicates/phone/valid.rb +41 -0
  237. data/app/models/atlas_engine/address_validation/validators/predicates/predicate.rb +37 -0
  238. data/app/models/atlas_engine/address_validation/validators/predicates/province/exists.rb +43 -0
  239. data/app/models/atlas_engine/address_validation/validators/predicates/province/valid_for_country.rb +48 -0
  240. data/app/models/atlas_engine/address_validation/validators/predicates/street/building_number_in_address1.rb +45 -0
  241. data/app/models/atlas_engine/address_validation/validators/predicates/street/building_number_in_address1_or_address2.rb +43 -0
  242. data/app/models/atlas_engine/address_validation/validators/predicates/street/present.rb +35 -0
  243. data/app/models/atlas_engine/address_validation/validators/predicates/zip/present.rb +58 -0
  244. data/app/models/atlas_engine/address_validation/validators/predicates/zip/valid_for_country.rb +45 -0
  245. data/app/models/atlas_engine/address_validation/validators/predicates/zip/valid_for_province.rb +55 -0
  246. data/app/models/atlas_engine/address_validation/validators/predicates/zip/zip_base.rb +25 -0
  247. data/app/models/atlas_engine/address_validation/zip_truncator.rb +32 -0
  248. data/app/models/atlas_engine/application_record.rb +8 -0
  249. data/app/models/atlas_engine/coded_error.rb +18 -0
  250. data/app/models/atlas_engine/coded_errors.rb +17 -0
  251. data/app/models/atlas_engine/country_import.rb +44 -0
  252. data/app/models/atlas_engine/country_profile.rb +270 -0
  253. data/app/models/atlas_engine/country_profile_ingestion_subset.rb +42 -0
  254. data/app/models/atlas_engine/country_profile_subset_base.rb +22 -0
  255. data/app/models/atlas_engine/country_profile_validation_subset.rb +48 -0
  256. data/app/models/atlas_engine/country_repository.rb +110 -0
  257. data/app/models/atlas_engine/elasticsearch/client.rb +116 -0
  258. data/app/models/atlas_engine/elasticsearch/client_interface.rb +89 -0
  259. data/app/models/atlas_engine/elasticsearch/repository.rb +246 -0
  260. data/app/models/atlas_engine/elasticsearch/repository_interface.rb +82 -0
  261. data/app/models/atlas_engine/elasticsearch/response.rb +20 -0
  262. data/app/models/atlas_engine/event.rb +12 -0
  263. data/app/models/atlas_engine/field_decompounder.rb +36 -0
  264. data/app/models/atlas_engine/index_configuration_factory.rb +188 -0
  265. data/app/models/atlas_engine/post_address.rb +114 -0
  266. data/app/models/atlas_engine/post_address_importer.rb +34 -0
  267. data/app/models/atlas_engine/services/service_helper.rb +21 -0
  268. data/app/models/atlas_engine/services/validation.rb +65 -0
  269. data/app/models/atlas_engine/services/validation_eligibility.rb +18 -0
  270. data/app/models/atlas_engine/street.rb +34 -0
  271. data/app/tasks/maintenance/atlas_engine/elasticsearch_index_create_task.rb +106 -0
  272. data/app/tasks/maintenance/atlas_engine/geo_json_import_task.rb +29 -0
  273. data/app/views/atlas_engine/connectivity/index.html.erb +50 -0
  274. data/app/views/atlas_engine/country_imports/index.html.erb +49 -0
  275. data/app/views/atlas_engine/country_imports/show.html.erb +73 -0
  276. data/app/views/layouts/atlas_engine/application.html.erb +15 -0
  277. data/config/initializers/1.ruby_patches.rb +18 -0
  278. data/config/initializers/sorbet.rb +5 -0
  279. data/config/initializers/worldwide.rb +5 -0
  280. data/config/locales/internal/en.yml +14 -0
  281. data/config/routes.rb +17 -0
  282. data/db/data/address_synonyms/index_configurations/default.yml +141 -0
  283. data/db/data/country_profiles/default.yml +23 -0
  284. data/db/data/transcriber.yml +760 -0
  285. data/db/data/validation_pipelines/es.yml +58 -0
  286. data/db/data/validation_pipelines/es_street.yml +58 -0
  287. data/db/data/validation_pipelines/local.yml +60 -0
  288. data/db/migrate/20230919173037_create_atlas_engine_post_addresses.rb +25 -0
  289. data/db/migrate/20231117142735_add_building_and_unit_ranges_column.rb +7 -0
  290. data/db/migrate/20231117143536_create_atlas_engine_country_imports.rb +11 -0
  291. data/db/migrate/20231117145844_create_atlas_engine_events_table.rb +13 -0
  292. data/db/migrate/20231123153554_add_unique_index_to_atlas_engine_post_addresses.rb +14 -0
  293. data/db/migrate/20231123154658_add_index_to_post_addresses_on_source_id_locale_country_code.rb +12 -0
  294. data/lib/atlas_engine/engine.rb +10 -0
  295. data/lib/atlas_engine/version.rb +6 -0
  296. data/lib/atlas_engine.rb +66 -0
  297. data/lib/tasks/atlas_engine/address_importer.rake +20 -0
  298. metadata +553 -0
@@ -0,0 +1,29 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module AtlasEngine
5
+ module Ch
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
+ if address[:city] == ["Biel/Bienne"]
16
+ address[:city] += ["Bienne", "Biel"]
17
+ elsif address[:city] == ["Emmenbrücke"]
18
+ address[:city] << "Emmen"
19
+ elsif address[:city] == ["Effretikon"]
20
+ address[:city] << "Illnau-Effretikon"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,74 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module AtlasEngine
5
+ module Ch
6
+ module AddressImporter
7
+ module Corrections
8
+ module OpenAddress
9
+ class LocaleCorrector
10
+ class << self
11
+ extend T::Sig
12
+
13
+ sig { params(address: Hash).void }
14
+ def apply(address)
15
+ province_code = address[:province_code]
16
+ zip = address[:zip].to_i
17
+
18
+ if [
19
+ "ZH",
20
+ "BE",
21
+ "LU",
22
+ "TG",
23
+ "SZ",
24
+ "AG",
25
+ "SO",
26
+ "AI",
27
+ "AR",
28
+ "GL",
29
+ "SG",
30
+ "SH",
31
+ "UR",
32
+ "ZG",
33
+ "OW",
34
+ "NW",
35
+ "BL",
36
+ "BS",
37
+ ].to_set.include?(province_code)
38
+ address[:locale] = "de"
39
+ elsif ["GE", "VD", "NE", "JU"].to_set.include?(province_code)
40
+ address[:locale] = "fr"
41
+ elsif province_code == "TI"
42
+ address[:locale] = "it"
43
+ elsif province_code == "FR"
44
+ address[:locale] = if zip < 1700 || zip >= 1720 && zip < 1734 || zip >= 1740 && zip < 1791
45
+ "fr"
46
+ else
47
+ "de"
48
+ end
49
+ elsif province_code == "VS"
50
+ address[:locale] = if zip < 3900 || zip >= 3960 && zip < 3970 || zip >= 3971 && zip < 3982
51
+ "fr"
52
+ else
53
+ "de"
54
+ end
55
+ elsif province_code == "GR"
56
+ if zip < 7000 || zip >= 7013 && zip < 7015 || zip >= 7016 && zip < 7023 ||
57
+ zip >= 7031 && zip < 7050 || zip >= 7077 && zip < 7104 || zip >= 7112 && zip < 7122 ||
58
+ zip >= 7126 && zip < 7130 || zip >= 7137 && zip < 7147 || zip >= 7151 && zip < 7202 ||
59
+ zip >= 7500 && zip < 7562 || zip >= 7602
60
+ address[:locale] = "it"
61
+ elsif (zip == 7130 || zip >= 7402 && zip < 7404 || zip == 7477) && address[:street].start_with?("Via")
62
+ address[:locale] = "it"
63
+ else
64
+ address[:locale] = "de"
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,40 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module AtlasEngine
5
+ module Ch
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: @country_code,
25
+ province_code: region,
26
+ region1: nil,
27
+ city: [city],
28
+ suburb: nil,
29
+ zip: postcode,
30
+ street: street,
31
+ building_and_unit_ranges: housenumber_and_unit(number, unit),
32
+ latitude: geometry(feature)&.at(1),
33
+ longitude: geometry(feature)&.at(0),
34
+ }
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,15 @@
1
+ id: CH
2
+ validation:
3
+ enabled: true
4
+ default_matching_strategy: local
5
+ index_locales:
6
+ - de
7
+ - fr
8
+ - it
9
+ ingestion:
10
+ open_address:
11
+ feature_mapper: AtlasEngine::Ch::AddressImporter::OpenAddress::Mapper
12
+ correctors:
13
+ open_address:
14
+ - AtlasEngine::Ch::AddressImporter::Corrections::OpenAddress::LocaleCorrector
15
+ - AtlasEngine::Ch::AddressImporter::Corrections::OpenAddress::CityCorrector
@@ -0,0 +1,15 @@
1
+ id: CH_DE
2
+ ingestion:
3
+ data_mapper: AtlasEngine::AddressValidation::Es::DataMappers::DecompoundingDataMapper
4
+ validation:
5
+ address_parser: AtlasEngine::De::ValidationTranscriber::AddressParser
6
+ normalized_components:
7
+ - region2
8
+ - region3
9
+ - region4
10
+ - city_aliases.alias
11
+ - suburb
12
+ - street_decompounded
13
+ decompounding_patterns:
14
+ street:
15
+ - (?<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,7 @@
1
+ street_synonyms:
2
+ - platz, pl
3
+ - strasse, str
4
+ city_synonyms:
5
+ - in, i
6
+ - sankt, st
7
+ - bei, b
@@ -0,0 +1,21 @@
1
+ city_synonyms:
2
+ - saint, st
3
+ - sainte, ste
4
+ - saints, sts
5
+ - saintes, stes
6
+ street_synonyms:
7
+ - allée, all
8
+ - avenue, av
9
+ - boulevard, bd
10
+ - centre, ctre
11
+ - chemin, chem
12
+ - impasse, imp
13
+ - passage, pas
14
+ - place, pl
15
+ - rond-point, rpt
16
+ - route, rte
17
+ - saint, st
18
+ - sainte, ste
19
+ - saints, sts
20
+ - saintes, stes
21
+ - sentier, sent
@@ -0,0 +1,6 @@
1
+ id: CZ
2
+ validation:
3
+ enabled: true
4
+ default_matching_strategy: es
5
+ address_parser: AtlasEngine::Dk::ValidationTranscriber::AddressParser
6
+ has_provinces: false
@@ -0,0 +1,19 @@
1
+ id: DE
2
+ ingestion:
3
+ settings:
4
+ min_zip_edge_ngram: "1"
5
+ max_zip_edge_ngram: "5"
6
+ data_mapper: AtlasEngine::AddressValidation::Es::DataMappers::DecompoundingDataMapper
7
+ validation:
8
+ has_provinces: true
9
+ address_parser: AtlasEngine::De::ValidationTranscriber::AddressParser
10
+ normalized_components:
11
+ - region2
12
+ - region3
13
+ - region4
14
+ - city_aliases.alias
15
+ - suburb
16
+ - street_decompounded
17
+ decompounding_patterns:
18
+ street:
19
+ - (?<name>\w+)(?<suffix>allee|gasse|kai|lande|pfad|platz|pl|ring|strasse|str|weg|zeile)(?:\b)
@@ -0,0 +1,64 @@
1
+ mappings:
2
+ properties:
3
+ street:
4
+ analyzer: street_indexing_analyzer
5
+ street_stripped:
6
+ analyzer: street_indexing_analyzer
7
+ street_decompounded:
8
+ type: text
9
+ analyzer: text_analyzer
10
+ fields:
11
+ keyword:
12
+ type: keyword
13
+ settings:
14
+ index:
15
+ analysis:
16
+ analyzer:
17
+ text_analyzer:
18
+ filter:
19
+ - lowercase
20
+ - german_normalization
21
+ - icu_folding
22
+ - strip_special_characters
23
+ keyword_analyzer:
24
+ filter:
25
+ - lowercase
26
+ - german_normalization
27
+ - icu_folding
28
+ - strip_special_characters
29
+ street_indexing_analyzer:
30
+ tokenizer: standard
31
+ filter:
32
+ - lowercase
33
+ - german_normalization
34
+ - icu_folding
35
+ - strip_special_characters
36
+ - street_suffix_decompounder
37
+ street_analyzer:
38
+ filter:
39
+ - lowercase
40
+ - german_normalization
41
+ - icu_folding
42
+ - strip_special_characters
43
+ - street_suffix_decompounder
44
+ - street_synonyms
45
+ city_analyzer:
46
+ filter:
47
+ - lowercase
48
+ - german_normalization
49
+ - icu_folding
50
+ - strip_special_characters
51
+ edge_ngram_analyzer:
52
+ filter:
53
+ - lowercase
54
+ - german_normalization
55
+ - icu_folding
56
+ - strip_special_characters
57
+ filter:
58
+ street_suffix_decompounder:
59
+ type: pattern_capture
60
+ preserve_original: "false"
61
+ patterns:
62
+ <% country_profile.decompounding_patterns(:street).each do |pattern| %>
63
+ - <%= pattern %>
64
+ <% end %>
@@ -0,0 +1,2 @@
1
+ street_synonyms:
2
+ - strasse, str
@@ -0,0 +1,19 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module AtlasEngine
5
+ module De
6
+ module ValidationTranscriber
7
+ class AddressParser < AtlasEngine::ValidationTranscriber::AddressParserBase
8
+ private
9
+
10
+ sig { returns(T::Array[Regexp]) }
11
+ def country_regex_formats
12
+ @country_regex_formats ||= [
13
+ /^#{STREET_NO_COMMAS}\s+#{BUILDING_NUM}$/,
14
+ ]
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,6 @@
1
+ id: DK
2
+ validation:
3
+ enabled: true
4
+ default_matching_strategy: es
5
+ has_provinces: false
6
+ address_parser: AtlasEngine::Dk::ValidationTranscriber::AddressParser
@@ -0,0 +1,3 @@
1
+ city_synonyms:
2
+ - NV, Nordvest
3
+ - SV, Sydvest
@@ -0,0 +1,21 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module AtlasEngine
5
+ module Dk
6
+ module ValidationTranscriber
7
+ class AddressParser < AtlasEngine::ValidationTranscriber::AddressParserBase
8
+ private
9
+
10
+ UNIT_NUM = /(?<unit_num>.+)/
11
+
12
+ sig { returns(T::Array[Regexp]) }
13
+ def country_regex_formats
14
+ @country_regex_formats ||= [
15
+ /^#{STREET_NO_COMMAS}\s+#{BUILDING_NUM}(,\s*#{UNIT_NUM})?$/,
16
+ ]
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ id: FO
2
+ validation:
3
+ enabled: true
4
+ default_matching_strategy: es
5
+ has_provinces: false
@@ -0,0 +1,28 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module AtlasEngine
5
+ module Fr
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
+ regex = /^(?<city>.*)\s\b(.+)\b\sArrondissement$/
16
+ m = regex.match(address[:city].first)
17
+
18
+ return if m.nil?
19
+
20
+ address[:city] = [m["city"]]
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ id: FR
2
+ ingestion:
3
+ correctors:
4
+ open_address:
5
+ - AtlasEngine::Fr::AddressImporter::Corrections::OpenAddress::CityCorrector
6
+ settings:
7
+ number_of_shards: "2"
8
+ min_zip_edge_ngram: "1"
9
+ max_zip_edge_ngram: "5"
10
+ validation:
11
+ address_parser: AtlasEngine::Fr::ValidationTranscriber::AddressParser
12
+ enabled: true
13
+ default_matching_strategy: es
@@ -0,0 +1,21 @@
1
+ city_synonyms:
2
+ - saint, st
3
+ - sainte, ste
4
+ - saints, sts
5
+ - saintes, stes
6
+ street_synonyms:
7
+ - allée, all
8
+ - avenue, av
9
+ - boulevard, bd
10
+ - centre, ctre
11
+ - chemin, chem
12
+ - impasse, imp
13
+ - passage, pas
14
+ - place, pl
15
+ - rond-point, rpt
16
+ - route, rte
17
+ - saint, st
18
+ - sainte, ste
19
+ - saints, sts
20
+ - saintes, stes
21
+ - sentier, sent
@@ -0,0 +1,34 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module AtlasEngine
5
+ module Fr
6
+ module ValidationTranscriber
7
+ class AddressParser < AtlasEngine::ValidationTranscriber::AddressParserBase
8
+ private
9
+
10
+ sig { override.returns(T::Array[Regexp]) }
11
+ def country_regex_formats
12
+ @country_regex_formats ||= [
13
+ /#{bldg_num_regex}\s+#{street_regex}/i,
14
+ /#{bldg_num_regex}\s+#{street_regex}(?:,.+)/i,
15
+ ]
16
+ end
17
+
18
+ sig { returns(Regexp) }
19
+ def bldg_num_regex
20
+ # examples:
21
+ # 100
22
+ # 100B
23
+ # 100 bis
24
+ @bldg_num_regex ||= T.let(/(?<building_num>\d+\s?([a-z]|bis|ter)?)/i, T.nilable(Regexp))
25
+ end
26
+
27
+ sig { returns(Regexp) }
28
+ def street_regex
29
+ @street_regex ||= T.let(/(?<street>.+)/, T.nilable(Regexp))
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,98 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module AtlasEngine
5
+ module Gb
6
+ module AddressValidation
7
+ module Es
8
+ class QueryBuilder < AtlasEngine::AddressValidation::Es::QueryBuilder
9
+ extend T::Sig
10
+
11
+ sig { params(address: AtlasEngine::AddressValidation::AbstractAddress, locale: T.nilable(String)).void }
12
+ def initialize(address, locale = nil)
13
+ super(address, locale)
14
+
15
+ @parsings = T.let(
16
+ AtlasEngine::Gb::ValidationTranscriber::FullAddressParser
17
+ .new(address: address).parse,
18
+ T::Array[ValidationTranscriber::ParsedAddress],
19
+ )
20
+ end
21
+
22
+ sig { override.returns(T::Hash[String, T.untyped]) }
23
+ def full_address_query
24
+ {
25
+ "query" => {
26
+ "dis_max" => {
27
+ "queries" => @parsings.map { |parsing| query_for_parsing(parsing) },
28
+ },
29
+ },
30
+ }
31
+ end
32
+
33
+ private
34
+
35
+ sig { params(parsing: ValidationTranscriber::ParsedAddress).returns(T.nilable(T::Hash[String, T.untyped])) }
36
+ def locality_clause(parsing)
37
+ return if parsing.double_dependent_locality.blank? &&
38
+ parsing.dependent_locality.blank? &&
39
+ parsing.post_town.blank?
40
+
41
+ {
42
+ "bool" => {
43
+ "should" => [
44
+ {
45
+ "match" => {
46
+ "region4" => { "query" => parsing.double_dependent_locality || "", "fuzziness" => "auto" },
47
+ },
48
+ },
49
+ {
50
+ "match" => {
51
+ "region3" => { "query" => parsing.dependent_locality || "", "fuzziness" => "auto" },
52
+ },
53
+ },
54
+ {
55
+ "nested" => {
56
+ "path" => "city_aliases",
57
+ "query" => {
58
+ "match" => {
59
+ "city_aliases.alias" => { "query" => parsing.post_town || "", "fuzziness" => "auto" },
60
+ },
61
+ },
62
+ },
63
+ },
64
+ ],
65
+ },
66
+ }
67
+ end
68
+
69
+ sig { params(parsing: ValidationTranscriber::ParsedAddress).returns(T.nilable(T::Hash[String, T.untyped])) }
70
+ def query_for_parsing(parsing)
71
+ {
72
+ "bool" => {
73
+ "should" => [
74
+ thoroughfare_clause(parsing),
75
+ locality_clause(parsing),
76
+ zip_clause,
77
+ ].compact,
78
+ },
79
+ }
80
+ end
81
+
82
+ sig { params(parsing: ValidationTranscriber::ParsedAddress).returns(T.nilable(T::Hash[String, T.untyped])) }
83
+ def thoroughfare_clause(parsing)
84
+ street_name = [parsing.dependent_street, parsing.street].compact.join(", ")
85
+
86
+ return if street_name.blank?
87
+
88
+ {
89
+ "match" => {
90
+ "street" => { "query" => street_name, "fuzziness" => "auto" },
91
+ },
92
+ }
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,10 @@
1
+ id: GB
2
+ validation:
3
+ has_provinces: true
4
+ query_builder: AtlasEngine::Gb::AddressValidation::Es::QueryBuilder
5
+ address_parser: AtlasEngine::ValidationTranscriber::AddressParserNorthAmerica
6
+ ingestion:
7
+ settings:
8
+ number_of_shards: "2"
9
+ min_zip_edge_ngram: "1"
10
+ max_zip_edge_ngram: "8"