"The award-winning and proprietary Google search technologies are the foundation for AdSense. We go beyond simple keyword matching to understand the content and context of web pages. Based on an algorithm that includes such factors as keyword analysis, word frequency, font size, and the overall link structure of the web, we know what a page is about, and can precisely match Google ads to each page."
https://www.google.com/adsense/overview