Code used in the paper Understanding patterns of loneliness in older long-term care users using natural language processing with free text case notes. This release contains the scripts and data processing steps used to extract and analyse loneliness indicators from social care case notes. The release is tied to the published version of the paper and is archived for reproducibility. This release also contains the data used for the tables and figures in the paper.