Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Twiiter String Elements Removal

$
0
0

Hi everybody,

I'm trying to write a sketch using Twitter API. I want to retrive tweets with a specific hashtag so I can use them. Unfortunately, I keep getting stuff like http related words in the middle of it.

Is there a practical way to prevent this or to remove them from the array?

This is the code I am using. These are all functions that are being called somewhere else.

Thank you so much

Best

    void makeobject(){


      //Make the twitter object and prepare the query
      twitterInstance = new TwitterFactory(cb.build()).getInstance();
      queryForTwitter = new Query("#summerparty");
      queryForTwitter.count(50);

    }

void createtquery() {


  //Try making the query request.
  try {
    QueryResult result = twitterInstance.search(queryForTwitter);
    tweets = (ArrayList) result.getTweets();
  } //END of try()
  catch (TwitterException te) {
    println("Couldn't connect: " + te);
  } //END Twitter Exception
} //END of void


void twitterdraw() {


  for (int i = 0; i < tweets.size (); i++) {
      Status t = (Status) tweets.get(i);
      String user = t.getUser().getName();
      String msg = t.getText();
      // Date d = t.getCreatedAt();
      println(msg);
      //text(msg, 150, 150);



 //Break the tweet into words
      String[] input = msg.split("#");
      for (int j = 0; j < input.length; j++) {
        //Put each word into the words ArrayList
        words.add(input[j]);
      }  //END of for()


  } //END of for()


  //Draw a word from the list
  int i = (int(random(0, words.size())) % words.size());
  String  word = words.get(i);

  //Put it on the stage
  text(word, 350, 110);


}

Viewing all articles
Browse latest Browse all 2896

Trending Articles