Which figure of speech is used in this text?
The moon is a friend for the lonesome to talk with.
—Carl Sandburg, "Moonlight and Maggots"

 - personification
 - simile
The text uses personification, giving human characteristics to nonhuman things.
The moon is a friend describes the moon as if it were human.