<commit_before>package com.jdroid.javaweb.twitter;

import org.slf4j.Logger;
import twitter4j.Status;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.conf.ConfigurationBuilder;
import com.jdroid.java.utils.LoggerUtils;
import com.jdroid.javaweb.context.Application;

public class TwitterConnector {
	
	private static final Logger LOGGER = LoggerUtils.getLogger(TwitterConnector.class);
	
	private TwitterFactory twitterFactory;
	
	public TwitterConnector() {
		ConfigurationBuilder cb = new ConfigurationBuilder();
		cb.setDebugEnabled(true);
		cb.setOAuthConsumerKey(Application.get().getAppContext().getTwitterOAuthConsumerKey());
		cb.setOAuthConsumerSecret(Application.get().getAppContext().getTwitterOAuthConsumerSecret());
		cb.setOAuthAccessToken(Application.get().getAppContext().getTwitterOAuthAccessToken());
		cb.setOAuthAccessTokenSecret(Application.get().getAppContext().getTwitterOAuthAccessTokenSecret());
		twitterFactory = new TwitterFactory(cb.build());
	}
	
	public void tweetSafe(String text) {
		try {
			if (Application.get().getAppContext().isTwitterEnabled()) {
				Status status = twitterFactory.getInstance().updateStatus(text);
				LOGGER.info("Successfully updated the status to [" + status.getText() + "].");
			} else {
				LOGGER.warn("Ignored tweet status [" + text + "].");
			}
		} catch (TwitterException e) {
			LOGGER.error("Error when posting on Twitter: [" + text + "]", e);
		}
	}
	
}<commit_msg>Twitter search<commit_after>package com.jdroid.javaweb.twitter;

import java.util.List;
import org.slf4j.Logger;
import twitter4j.Query;
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.conf.ConfigurationBuilder;
import com.jdroid.java.exception.UnexpectedException;
import com.jdroid.java.utils.LoggerUtils;
import com.jdroid.javaweb.context.Application;

public class TwitterConnector {
	
	private static final Logger LOGGER = LoggerUtils.getLogger(TwitterConnector.class);
	
	private TwitterFactory twitterFactory;
	
	public TwitterConnector() {
		ConfigurationBuilder cb = new ConfigurationBuilder();
		cb.setDebugEnabled(true);
		cb.setOAuthConsumerKey(Application.get().getAppContext().getTwitterOAuthConsumerKey());
		cb.setOAuthConsumerSecret(Application.get().getAppContext().getTwitterOAuthConsumerSecret());
		cb.setOAuthAccessToken(Application.get().getAppContext().getTwitterOAuthAccessToken());
		cb.setOAuthAccessTokenSecret(Application.get().getAppContext().getTwitterOAuthAccessTokenSecret());
		twitterFactory = new TwitterFactory(cb.build());
	}
	
	public void tweetSafe(String text) {
		try {
			if (Application.get().getAppContext().isTwitterEnabled()) {
				Status status = twitterFactory.getInstance().updateStatus(text);
				LOGGER.info("Successfully updated the status to [" + status.getText() + "].");
			} else {
				LOGGER.warn("Ignored tweet status [" + text + "].");
			}
		} catch (TwitterException e) {
			LOGGER.error("Error when posting on Twitter: [" + text + "]", e);
		}
	}
	
	public List<Status> searchTweets(String queryText) {
		Twitter twitter = twitterFactory.getInstance();
		Query query = new Query(queryText);
		try {
			return twitter.search(query).getTweets();
		} catch (TwitterException e) {
			throw new UnexpectedException(e);
		}
	}
	
}
{'fraction_non_alphanumeric': 0.12335722819593788, 'fraction_numerical': 0.0035842293906810036, 'mean_word_length': 5.765656565656566, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4640335', 'n_tokens_mistral': 1072, 'n_tokens_neox': 958, 'n_words': 175}