Take all the comments expressed on Twitter, crunch them with an analytics program and you can get a sense of the mood of a city, state or country.

US researchers say they have come up with such a tool, called a "hedonometer," which is effectively a happiness sensor.

The project at www.hedonometer.org, which went live on Tuesday, has been collecting data for five years, measuring the ups and downs of the moods expressed on the popular messaging platform.

The tool analyzes roughly 10 percent of all tweets posted in English, giving a sense of the mood of the Internet community, albeit with a heavy weighting in the United States.

The researchers found that the day of the Boston Marathon bombings, April 15, was the saddest day measured in five years, slightly worse than the day of the Newtown, Connecticut school massacre.

The happiest days were on holidays such as Christmas or Thanksgiving.

The hedonometer draws on the "psychological valence" of about 10,000 words. Using a scale of one to nine, "happy" is ranked 8.30, "hahaha" 7.94, "cherry" 7.04. At the bottom, "crash" is rated 2.60, "war" 1.80, and "jail" 1.76.

The team collects some 50 million tweets from around the world each day "then we basically toss all the words into a huge bucket," to calculate a happiness score, said lead researcher Peter Dodds.

"It gives us some great insight and it works in real time," Dodds told AFP.

The day of the US raid which killed Osama bin Laden was ranked as a sadder-than-average day, according to Dodds, because of the negative words expressed in tweets.

"It happened to a negative person, and the texture of that day is talking about death, a negative event," he said.

The hedonometer's initial measurements come from English-language tweets, but researchers say the hedonometer will soon be drawing in other data streams, like Google Trends, The New York Times, blogs, CNN transcripts, and text captured by the link-shortening service Bitly. And it will be mining data in 12 languages.

The research team in February released data from geo-tagged tweets from cell phones, to rate the happiest and saddest cities in America: Napa, California, was at the top and Beaumont, Texas, at the bottom.

While some may be unnerved by the results, Dodds said the project can be useful because "we are good at making things better if we can measure them."

The hedonometer project was led by Dodds and Chris Danforth at the Computational Story Lab at the University of Vermont with Mitre, a not-for-profit group that operates federal research centers and has expertise in big data analytics.

The term hedonometer was coined by Irish-born economist and philosopher Francis Edgeworth in the late 19th century, who spoke of "an ideally perfect instrument... continually registering the height of pleasure experienced by an individual."

The researchers say that by aggregating the data from tweets, one can get a better picture of a national or regional mood than by looking at individual comments.

"Many of the articles written in response to the bombing have quoted individual tweets reflecting qualitative micro-stories," said Danforth.

"Our instrument reflects a kind of quantitative macro-story, one that journalists can use to bring big data into an article attempting to characterize the public response to the incident."

The researchers say they are trying to improve the tool to get information from two-word expressions, which they call "molecules," as opposed to single words, dubbed "atoms."

"The key piece is not whether we're correctly measuring atoms and molecules," says Brian Tivnan, a researcher from Mitre.

"It's the relative context that is so important: which is why the sudden drop from the Boston Marathon bombings jumps out at you. The hedonometer shows the pulse of a society."