Removing stop words from text files in core java

I have some text files and a file of stopwords(a,an,is,the,for,what,when,where,by,between…)I need a program like it should remove stop words from my files and output is like only keywords(other than stop words) and its frequency from respective files…plss hel me guys…thanks in advance

This snippet might help you fro removing Stopwords from File:

import java.util.;
import java.util.regex.Pattern;
import java.io.
;

public class StopWords
{
private static String RESULT_FNAME = “Output.txt”;

    public static Boolean isStopWord(String word, String[] stopWords)
    {
		boolean found = false;  
    }

    public static int compareWords(String word1, String word2)
    {
		return word1.compareToIgnoreCase(word2);
    }

	public static String[] readStopWords(String stopWordsFilename) 
	{
		String[] stopWords = null;
		try
		{
			Scanner stopWordsFile = new Scanner(new File(stopWordsFilename));
			int numStopWords = stopWordsFile.nextInt();
			
			stopWords = new String[numStopWords];
			
			for (int i = 0; i < numStopWords; i++)
			    stopWords[i] = stopWordsFile.next();

			stopWordsFile.close();
		}
		catch (FileNotFoundException e)
		{
			System.err.println(e.getMessage());
			System.exit(-1);
		}

		return stopWords;
	 }
	 
	public static void removeStopWords(String textFilename, String[] stopWords)
	{
		String word;
		
		try
    	{
			Scanner textFile = new Scanner(new File(textFilename));
			textFile.useDelimiter(Pattern.compile("[ \n\r\t,.;:?!'\"]+"));

			PrintWriter outFile = new PrintWriter(new File(RESULT_FNAME));
			
			while (textFile.hasNext())
			{
				word = textFile.next();
				
				if (isStopWord(word, stopWords))
				    System.out.print(word + " ");
				else
				    outFile.print(word + " ");
			}
	
			System.out.println("Output File " + RESULT_FNAME);
    	}
		catch (FileNotFoundException e)
	    {
			System.err.println(e.getMessage());
			System.exit(-1);
	    }
	    finally
	    {
			textFile.close();
			outFile.close();
	    }
	}

    public static void main(String[] arg)
    {
		Scanner keyboard = new Scanner(System.in);
		System.out.print("Input StopWord File: ");
		String[] stopWords = readStopWords(keyboard.next());

		System.out.print("Input file from which stopword to be removed: ");
		removeStopWords(keyboard.next(), stopWords);

    }
}

**

please help me to run this code on eclipse…because i am not familiar with it.i dond know how to input the stop word file
--------------------alt text--------------------

**

you just need to read the file word by word.
Then you replace the stop words by an empty string “”.

i wrote a opensource java library called “exude” which will filter stopping words from given input text data or file or web link. library is available in maven repository and full source code in github feel free to fork the code and rise bugs/suggestions/requirement on library in github.

demo: https://exude.herokuapp.com/

github: https://github.com/uttesh/exude

Hello @sneha_12,

Please share the code that you have already written, and the issues that you ran into.