public static void main(String[] args) throws TwitterException, IOException {
   Twitter twitter = TwitterFactory.getSingleton();
   JLanguageTool langTool = new JLanguageTool(new AmericanEnglish());
   List<String> twts = new ArrayList<String>();
   for (String arg : args) {
     Query query = new Query(arg);
     QueryResult result;
     int counter = 0;
     do {
       result = twitter.search(query);
       List<Status> tweets = result.getTweets();
       for (Status tweet : tweets) {
         if (isEligible(tweet)) {
           System.out.println("@" + tweet.getUser().getScreenName() + " - " + tweet.getText());
           System.out.println(tweet.getLang());
           twts.add(tweet.getText());
           counter++;
         }
       }
     } while ((query = result.nextQuery()) != null && counter < 5);
   }
   for (String str : twts) {
     List<RuleMatch> matches = langTool.check(str);
     for (RuleMatch match : matches) {
       System.out.println(
           "Potential error at line "
               + match.getLine()
               + ", column "
               + match.getColumn()
               + ": "
               + match.getMessage());
       System.out.println("Suggested correction: " + match.getSuggestedReplacements());
     }
   }
 }
  public void grab(Date timeLimit) {
    log.info("Twitter grabber started...");
    Twitter twitter = new TwitterFactory().getInstance();

    List<Brand> brandList = handler.getBrandProvider().getAllBrands();
    ArticleProvider articleProvider = handler.getArticleProvider();

    for (Brand b : brandList) {
      Query query = new Query(b.getName());
      query.setRpp(PAGE_SIZE);
      query.setLang("ru");
      query.setResultType(Query.MIXED);

      List<Tweet> resultTweets = new LinkedList<Tweet>();
      QueryResult queryResult;
      int pageNumber = 1;

      try {
        do {
          query.setPage(pageNumber);
          queryResult = twitter.search(query);
          resultTweets.addAll(queryResult.getTweets());
          pageNumber++;
          log.info(pageNumber);
        } while (ISSUANCE_SIZE > resultTweets.size());
      } catch (TwitterException e) {
        throw new RuntimeException(e);
      }
      log.info("tweets in da111y: " + resultTweets.size());
      twitter = null;
      twitter = new TwitterFactory().getInstance();

      for (Tweet t : resultTweets) {
        articleProvider.writeArticleToDataStore(
            new Article(-1, b.getId(), 2, "", t.getText(), "", getSimpleTime(t.getCreatedAt()), 1));
      }
    }
    log.info("twitter grabber finished succesful.");
  }