You need to design an algorithm that is able to tell you the trends.
To do that you first need to define what a trend is, e.g. a term or a person's name that was used in a twitter feed. Or even consider if some tweet has been re-tweeted and how often / in which period.
So you need to analyse each feed, extract the information you're looking for and then combine it with the time-information to say what's trending, e.g. used more or less in a period compared to some other period.
Parsing of twitter messages can be done with regular expressions.
The keywords can then be saved into a database which acts like an index.
You can then use a data language like SQL to obtain information about trends from the normalized data.
You normally start with simple scripts to do that to test your algorithm.
As it's undefined in your question for what kind of trends you're looking for, the question can only be generally answered. However some tips:
- Obtain tweets only once, cache them (looks like you already have this).
- The more data you have, the better you can test your algorithm/system, so obtain data first.
- Define processes you can apply onto that cached data, like the parsing, normalizing and which database backend to use.
- Allow your system to have multiple trend algorithms so you can test them against each other.
- Find out about stop-words (search engines are another related topic that need to filter out unimportant text-information) in your language / domain.