tools/smaz: refactor dictionary evaluation in a standalone subprogram