Hillary Clinton and Bernie Sanders speak during the Democratic presidential debate on CNN on Oct. 13 in Las Vegas. (John Locher/ AP)

Early in the presidential campaign, television news outlets largely ignored Bernie Sanders, instead focusing on his rival for the Democratic nomination, Hillary Clinton. His supporters saw this disparate treatment as just more evidence of systematic bias in the media -- especially when compared with the attention broadcast and cable anchors have lavished on Republican Donald Trump.

Since the beginning of the year, however, Sanders and Clinton have received nearly equal time on television, although Clinton still retains a slight advantage.

The chart below shows how often candidates were mentioned on national cable television and on several local stations in Philadelphia and San Francisco. The data is drawn from the TV News Archive, a free online library, and compiled by the GDELT Project.

The media's attention to Sanders came suddenly, after months in which Sanders's poll numbers had been gradually improving. As the chart below shows, it took a little while for the press to catch up with the Sanders campaign.

The polling and the attention from the media feed into each other. Political scientists argue that attention from the media is one of the most important factors driving candidates' poll numbers.

At the same time, if Sanders's numbers keep improving the Democratic race will get more interesting. The contest has long been considered a lock for Clinton, but viewers might pay more attention to it if the outcome is in doubt. In that case, stations would cover the race more closely.

Philip Bump contributed to this post.

More from Wonkblog:

What Republicans and Bernie Sanders get wrong about Wall Street

Are you a democratic socialist like Bernie Sanders? Take the quiz.

Bernie Sanders' reparations problem