use of edu.illinois.cs.cogcomp.lbjava.parse.LinkedVector in project cogcomp-nlp by CogComp.
the class WordSplitter method main.
/**
* Run this program on a file containing plain text, and it will produce
* the same text on <code>STDOUT</code> rearranged so that each line
* contains exactly one sentence, and so that character sequences deemed to
* be "words" are delimited by whitespace.
* <p/>
* <p> Usage:
* <code> java edu.illinois.cs.cogcomp.lbjava.edu.illinois.cs.cogcomp.lbjava.nlp.WordSplitter <file name> </code>
*
* @param args The command line arguments.
**/
public static void main(String[] args) {
String filename = null;
try {
filename = args[0];
if (args.length > 1)
throw new Exception();
} catch (Exception e) {
System.err.println("usage: java edu.illinois.cs.cogcomp.lbjava.edu.illinois.cs.cogcomp.lbjava.nlp.WordSplitter <file name>");
System.exit(1);
}
WordSplitter splitter = new WordSplitter(new SentenceSplitter(filename));
for (LinkedVector s = (LinkedVector) splitter.next(); s != null; s = (LinkedVector) splitter.next()) {
if (s.size() > 0) {
Word w = (Word) s.get(0);
System.out.print(w.form);
for (w = (Word) w.next; w != null; w = (Word) w.next) System.out.print(" " + w.form);
}
System.out.println();
}
}
Aggregations