A method for the automatic classification of chemical structures