Class: AtlasEngine::AddressValidation::Es::TermVectors
- Inherits:
-
Object
- Object
- AtlasEngine::AddressValidation::Es::TermVectors
- Extended by:
- T::Sig
- Defined in:
- app/models/atlas_engine/address_validation/es/term_vectors.rb
Instance Method Summary collapse
-
#initialize(term_vectors_hashes:, candidates:) ⇒ TermVectors
constructor
A new instance of TermVectors.
- #set_candidate_sequences ⇒ Object
Constructor Details
#initialize(term_vectors_hashes:, candidates:) ⇒ TermVectors
Returns a new instance of TermVectors.
16 17 18 19 |
# File 'app/models/atlas_engine/address_validation/es/term_vectors.rb', line 16 def initialize(term_vectors_hashes:, candidates:) @term_vectors_hashes = term_vectors_hashes @candidates = candidates end |
Instance Method Details
#set_candidate_sequences ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/atlas_engine/address_validation/es/term_vectors.rb', line 22 def set_candidate_sequences candidates_by_id = candidates.index_by(&:id) term_vectors_hashes.map do |candidate_result| candidate = candidates_by_id[candidate_result["_id"]] next if candidate.nil? candidate_result["term_vectors"].map do |component_name, terms_hash| component_name = component_name.delete_suffix("_decompounded") # city values are indexed as city_aliases.alias, but Atlas still uses :city as the component name component_name = "city" if component_name == "city_aliases.alias" component = candidate.component(component_name.to_sym) sorted_tokens = Token.from_field_term_vector(terms_hash) set_sequences(component, sorted_tokens) end end end |