Java String Tokenize removeStopWords(String[] tokens, Set stopWords)

Here you can find the source of removeStopWords(String[] tokens, Set stopWords)

Description

remove Stop Words

License

Open Source License

Declaration

public static String[] removeStopWords(String[] tokens, Set<String> stopWords) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

import java.util.Set;

public class Main {
    public static String[] removeStopWords(String[] tokens, Set<String> stopWords) {
        List<String> res = new ArrayList<String>();
        for (String token : tokens) {
            if (!stopWords.contains(token))
                res.add(token);//from   www  .  j  a v a2 s.co m
        }
        return res.toArray(new String[0]);
    }

    public static double[] add(double[] a, double b) {
        for (int i = 0; i < a.length; i++) {
            a[i] += b;
        }
        return a;
    }

    public static double[] add(double[] a, double scale, double[] b) {
        for (int i = 0; i < a.length; i++) {
            a[i] += scale * b[i];
        }
        return a;
    }
}

Related

  1. parseNMTokens(String nmTokens)
  2. parseString(String in, String token)
  3. readTokens(String line)
  4. removeEmptyStrings(String[] tokens)
  5. removeMatchingRegex(String regex, String replacement, String[] tokens, boolean removeEmpty)
  6. stringTokenizer(String in)
  7. substringsBetween(final String str, final String open, final String close, boolean tokenReservedFlag)
  8. tokenArray(StringTokenizer st)
  9. tokenize(final String aInput, final String aDelimiters)