The clustering of H β + [O III] and [O II] emitters since z ∼ 5: dependencies with line luminosity and stellar mass