Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/tasks/soundex/oracle.py # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / tasks / soundex / oracle.py` 25 lines ยท 825 bytes Raw Blame History 1 # Independent reference for "Soundex" (Python 3, standard library only). 2 # expected.txt is this program's stdout; omc never produced it. 3 groups = {"bfpv": "1", "cgjkqsxz": "2", "dt": "3", "l": "4", "mn": "5", "r": "6", "hw": "h"} 4 def code(c): 5 for k, v in groups.items(): 6 if c in k: 7 return v 8 return "0" 9 def soundex(name): 10 s = name.lower() 11 out = s[0].upper() 12 prev = code(s[0]) 13 for c in s[1:]: 14 d = code(c) 15 if d == "h": 16 continue 17 if d == "0": 18 prev = d 19 continue 20 if d != prev: 21 out += d 22 prev = d 23 return (out + "000")[:4] 24 for name in ['Robert', 'Rupert', 'Rubin', 'Ashcraft', 'Ashcroft', 'Tymczak', 'Pfister', 'Honeyman', 'Lee', 'Gutierrez', 'Jackson', 'VanDeusen']: 25 print(name, soundex(name))