Example #1
0
 @Override
 protected Void call() throws Exception {
   while (!isCancelled()) {
     Tweet tweet = tweetSetData.getNextOrRandomTweet(5, 10);
     if (null != tweet) {
       //                parents.put(createTweetInfoBox(tweets.take()));
       Platform.runLater(() -> wordle.setTweet(tweet));
       addTweetToCloud(tweet);
       Thread.sleep(3000);
       Platform.runLater(() -> wordle.setLayoutMode(Wordle.LayoutMode.TWEET));
       Thread.sleep(8000);
       Platform.runLater(() -> wordle.setLayoutMode(Wordle.LayoutMode.WORDLE));
       Thread.sleep(5000);
       //                removeTweetFromCloud(tweetWords);
       Platform.runLater(
           () ->
               wordle.setWords(
                   tweetSetData
                       .getTree()
                       .entrySet()
                       .stream()
                       .sorted(TweetSetData.COMPARATOR.reversed())
                       .limit(TagTweets.NUM_MAX_WORDS)
                       .map(
                           (java.util.Map.Entry<String, Long> entry) ->
                               new Word(entry.getKey(), entry.getValue()))
                       .collect(Collectors.toList())));
       Thread.sleep(5000);
     }
   }
   return null;
 }
Example #2
0
 private void createWordle() {
   if (null == wordle) {
     wordle = new Wordle();
     hWordle.getChildren().setAll(wordle);
     wordle.prefWidthProperty().bind(hWordle.widthProperty());
     wordle.prefHeightProperty().bind(hWordle.heightProperty());
   }
   Platform.runLater(
       () -> {
         wordle.setWords(
             tweetSetData
                 .getTree()
                 .entrySet()
                 .stream()
                 .sorted(TweetSetData.COMPARATOR.reversed())
                 .limit(NUM_MAX_WORDS)
                 .map(entry -> new Word(entry.getKey(), entry.getValue()))
                 .collect(Collectors.toList()));
         wordle.setTweet(tweetSetData.getNextOrRandomTweet(0, 3));
       });
 }
Example #3
0
 private Set<Word> addTweetToCloud(Tweet tweet) {
   //        System.out.println("Add tweet to cloud");
   String text =
       tweet
           .getTextWithout(UrlTweetEntry.class)
           .getTextWithout(UserMentionTweetEntry.class)
           .get();
   Set<Word> tweetWords =
       pattern
           .splitAsStream(text)
           .map(l -> trimTail(l)) // no bad word tails
           .filter(l -> l.length() > 2) // longer than 2 characters
           .filter(l -> !urlPattern.matcher(l).matches()) // no url
           .filter(l -> !StopList.contains(l)) // not in stoplist
           .map(l -> new Word(l, -2)) // convert to Word
           .collect(Collectors.toSet()); // collect
   List<Word> words = new ArrayList<>(wordle.wordsProperty().get());
   tweetWords.removeAll(words);
   words.addAll(tweetWords);
   Platform.runLater(() -> wordle.wordsProperty().set(words));
   return tweetWords;
 }