A sex offender from Swindon has been jailed and police have praised a teenage girl for her bravery in bringing him to justice.