In this paper we describe a method which combines sentiment analysis with machine learning techniques and/or multivariate statistical analysis. By applying this methodology it is possible to classify a collection of texts into two or more groups or clusters. On the basis of a number of previously defined clusters, the novelty of the outlined approach is the use of the sentiment analysis results as input to the machine learning model or multivariate statistical analysis. Once the classifier has been obtained, we can assign a given text into one of the pre-established clusters. The groups or clusters can represent different time periods, classes of texts transcribed from different conversations, etc. The method is illustrated through an example taken from one of the two studies in which we have applied this methodology. In one of the studies, the method was used to classify press news of a volcanic eruption, while in the other study it was used to classify the conversations recorded between a chatbot with different kinds of speakers (humans or chatbots). This last study was the seminal work in which we introduced this methodology.