PurposeThe purpose of this paper is to propose an attention alignment method for opinion mining of massive open online course (MOOC) comments. Opinion mining is essential for MOOC applications. In this study, the authors analyze some of bidirectional encoder representations from transformers (BERT’s) attention heads and explore how to use these attention heads to extract opinions from MOOC comments.Design/methodology/approachThe approach proposed is based on an attention alignment mechanism with the following three stages: first, extracting original opinions from MOOC comments with dependency parsing. Second, constructing frequent sets and using the frequent sets to prune the opinions. Third, pruning the opinions and discovering new opinions with the attention alignment mechanism.FindingsThe experiments on the MOOC comments data sets suggest that the opinion mining approach based on an attention alignment mechanism can obtain a better F1 score. Moreover, the attention alignment mechanism can discover some of the opinions filtered incorrectly by the frequent sets, which means the attention alignment mechanism can overcome the shortcomings of dependency analysis and frequent sets.Originality/valueTo take full advantage of pretrained language models, the authors propose an attention alignment method for opinion mining and combine this method with dependency analysis and frequent sets to improve the effectiveness. Furthermore, the authors conduct extensive experiments on different combinations of methods. The results show that the attention alignment method can effectively overcome the shortcomings of dependency analysis and frequent sets.