Hello gentlemen. I have a question over here. with the following piece of code i want to extract data from a document. The question is how can i assign the values Sentences, Words in the Array.
String data[][]; //[files][sentences][words]
public void ScanSearch() {
for (int i = 0; i < files.length; i++) {
try {
Scanner scanner = new Scanner(new File(files[i][1]));
while (scanner.hasNextLine()){
String line = scanner.nextLine();
Pattern p = Pattern.compile("[\\.\\!\\?]\\s+", Pattern.MULTILINE);
Scanner lineScanner = new Scanner(line);
lineScanner.useDelimiter(p);
while (lineScanner.hasNext()){
String Sentence = lineScanner.next();
System.out.println(Sentence);
String[] words = Sentence.split(" ");
for (int j=0; i<words.length; j++){
System.out.println(words[j]);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
help greatly appreciated.