The injection-seeded terahertz parametric generation (is-TPG) spectroscopy is a new powerful technique that can be used for sample identification including inspection of drugs hidden inside mail envelopes. In the present paper algorithms of automatic sample identification on the basis of measured absorption spectra are discussed. We check the applicability of these algorithms for identification of samples in different real-life situations, e.g. samples of pure compounds, hidden in the envelopes, polycrystalline samples with different grain size, mixture compound samples, etc.