tools/smaz: refactor dictionary processing in a dedicated procedure