コード例 #1
0
ファイル: BaseRascalREPL.java プロジェクト: aruntezz/rascal
 private static String unescapeKeywords(String term) {
   return splitIdentifiers
       .splitAsStream(term + " ") // add space such that the ending "::" is not lost
       .map(BaseRascalREPL::unescapeKeyword)
       .collect(Collectors.joining("::"))
       .trim();
 }
コード例 #2
0
  public static void main(String[] args) throws IOException {
    Pattern wordSeparator = Pattern.compile("[\\P{L}]+");

    try (Stream<String> lines = Files.lines(Paths.get("frankenstein.txt"))) {
      System.out.println(
          lines.flatMap(l -> wordSeparator.splitAsStream(l)).filter(x -> x.length() > 10).count());
    }
  }
コード例 #3
0
ファイル: BaseRascalREPL.java プロジェクト: aruntezz/rascal
 private static Collection<String> escapeKeywords(Collection<String> suggestions) {
   return suggestions
       .stream()
       .map(
           s ->
               splitIdentifiers
                   .splitAsStream(s + " ") // add space such that the ending "::" is not lost
                   .map(BaseRascalREPL::escapeKeyword)
                   .collect(Collectors.joining("::"))
                   .trim())
       .collect(Collectors.toList());
 }
コード例 #4
0
ファイル: TagTweets.java プロジェクト: siggi12/TweetwallFX
 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;
 }
コード例 #5
0
 public Stream<String> parse(String text) {
   return SPLIT_PATTERN.splitAsStream(text).map(String::toLowerCase);
 }