Extremely red quasars from SDSS, BOSS and WISE: classification of optical spectra