I need the specification and implementation of a new data type that holds terms extracted from document(s). Such a data type will not allow duplication of terms in each instance. A minimum of:
1 creator method,
3 mutator methods,
3 observer methods are required.
Also,a separate test program is to be implemented to read a text document (provided by a user) and extract each term contained in the document. Extracted terms from a single document will be stored in an instance of the newly created data type,
i.e. for each text document, there will be an instance of the newly created data to hold terms extracted from the document.
I have tried this this code but it didn't work, I am stucked:
import java.util.*;
import java.io.*;
public class TermExtractor; {
Scanner reader = new Scanner (new File ("terms.txt");
public void readFileLine(Scanner reader) {
Iterator<String> itr = reader.iterator();
while (reader.itr = reader.iterator();
String termLine = reader.nextLine();
Scanner LineTermProcess = new Scanner (termLine);
while (termLine.hasNext()) {
String term = lineTermProcess.next();
System.out.print(term);
}
System.out.println();
}
}
pubic void termReadBefore(Scanner reader) {
iterator<String> itrt = reader.iterator();
while (reader.hasNextLine()) {
String termLineBefore = reader.nextLine();
Scanner lineTermProcessBefore = new Scanner(termLineBefore);
while (termLineBefore.hasNext()) {
Do {
String termBefore = lineTermProcessBefore.next();
System.out.print(termBefore);
while (termBefore != lineTermProcessBefore())
}
System.out.println();
}
}
}