WSS_NamedEntityValidator.rb
# Normalize SSN by adding dashes or replacing spaces with dashes.
# i.e. 123456789 and 1234 56 789 => 123-45-6789
#
# @param entity [Entity] the extracted entity
# @param worker_item [WorkerItem] the item being processed
# @return [Entity] normalized ssn entity
Normalize SSN by adding dashes or replacing spaces with dashes.
Normalize SSN by adding dashes or replacing spaces with dashes .
def ssn_entity(entity, worker_item)
  value = entity.get_value
  return entity if value.include?('-')
  if value.length == 9
    value = "#{value[0, 3]}-#{value[4, 2]}-#{value[6, 4]}"
  else
    value.gsub!(' ', '-')
  end
  worker_item.create_entity(entity.get_type, value)
end
def ssn_entity ( entity , worker_item ) value = entity . get_value return entity if value . include? ( '-' ) if value . length == 9 value = "#{value[0, 3]}-#{value[4, 2]}-#{value[6, 4]}" else value . gsub! ( ' ' , '-' ) end worker_item . create_entity ( entity . get_type , value ) end
Normalize SSN by adding dashes or replacing spaces with dashes.
Normalize SSN by adding dashes or replacing spaces with dashes .
# Add dash if no separator # Convert space to dash
normalized ssn entity
normalized ssn entity
Entity
entity
the extracted entity
the extracted entity
worker_item
the item being processed
the item being processed