Semiparametric maximum likelihood inference for truncated or biased-sampling data