Teaching learners about the common structural patterns used in different types of texts, such as the abstract and introduction of research papers, has proved successful in many ESP reading and writing courses. However, a major problem faced by researchers when analyzing texts is the vast amount of time needed to conduct the analysis. This has led to many studies reporting only preliminary findings, based on a small corpus of target texts. In this paper, we propose a computer system that uses machine learning to automatically identify the structure of texts, enabling researchers to quickly and effectively process very large corpora. The system also has applications in the classroom as a teacher resource when evaluating and selecting texts that highlight certain features, and as a student resource when conducting data-driven learning. To test the system, it was applied to abstracts from computer science journals and found to be fast and accurate. It was also assessed by practicing ESP teachers and learners and shown to be flexible, easy to use, and a practical aid in the classroom.