def double_metaphone(str)
primary, secondary, current = [], [], 0
original, length, last = "#{str} ".upcase, str.length, str.length - 1
if /^GN|KN|PN|WR|PS$/ =~ original[0, 2]
current += 1
end
if 'X' == original[0, 1]
primary << :S
secondary << :S
current += 1
end
while primary.length < 4 || secondary.length < 4
break if current > str.length
a, b, c = double_metaphone_lookup(original, current, length, last)
primary << a if a
secondary << b if b
current += c if c
end
primary, secondary = primary.join("")[0, 4], secondary.join("")[0, 4]
return primary, (primary == secondary ? nil : secondary)
end