fix bugs: MAX_ALLOWED_TYPOS not MAX_NUM_TYPOS and compile_regex is method not global