package io.github.atealxt.nlp.analysis.filter;

import io.github.atealxt.nlp.analysis.Filter;

import java.util.regex.Pattern;

public class StopWordFilter implements Filter {

	private static final Pattern PATTERN = Pattern.compile("[.\":'?,;!\\-_#(){}\\[\\]<>$*&%+^=]+");

	@Override
	public String filter(String input) {
		return PATTERN.matcher(input).replaceAll("");
	}
}

@@ -88,24 +88,275 @@
 .Filter;%0D%0A%0D%0A
+import java.io.BufferedReader;%0D%0Aimport java.io.FileInputStream;%0D%0Aimport java.io.IOException;%0D%0Aimport java.io.InputStream;%0D%0Aimport java.io.InputStreamReader;%0D%0Aimport java.nio.charset.StandardCharsets;%0D%0Aimport java.util.HashSet;%0D%0Aimport java.util.Set;%0D%0A
 import java.
@@ -466,16 +466,29 @@
  PATTERN
+_PUNCTUATIONS
  = Patte
@@ -544,107 +544,679 @@
 );%0D%0A
-%0D%0A%09@Override%0D%0A%09public String filter(String input) %7B%0D%0A%09%09return PATTERN.matcher(input).replaceAll(%22%22)
+%09private static final Set%3CString%3E STOPWORDS = new HashSet%3CString%3E();%0D%0A%0D%0A%09static %7B%0D%0A%09%09String str = null;%0D%0A%09%09try (InputStream file = new FileInputStream(Thread.currentThread().getContextClassLoader().getResource(%22stopwords.txt%22).getFile());%0D%0A%09%09%09%09BufferedReader reader = new BufferedReader(new InputStreamReader(file, StandardCharsets.UTF_8))) %7B%0D%0A%09%09%09while ((str = reader.readLine()) != null && !str.isEmpty()) %7B%0D%0A%09%09%09%09STOPWORDS.add(str);%0D%0A%09%09%09%7D%0D%0A%09%09%7D catch (IOException e) %7B%0D%0A%09%09%09e.printStackTrace();%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A%09@Override%0D%0A%09public String filter(String input) %7B%0D%0A%09%09String term = PATTERN_PUNCTUATIONS.matcher(input).replaceAll(%22%22);%0D%0A%09%09return STOPWORDS.contains(term) ? %22%22 : term
 ;%0D%0A%09

Optimize stop word filter.