Codebook code

First draft. Needs to be validated.

Dataset is temporary.