docs: public static void main(String[] args) throws IOException{
      if (args.length < 1) {
        System.err.println("usage: DocumentPreprocessor filename [OPTS]");
        return;
      }
  
      DocumentPreprocessor docPreprocessor = new DocumentPreprocessor(args[0]);
      String encoding = "utf-8";
      boolean printSentenceLengths = false;
  
      for (int i = 1; i < args.length; i++) {
        if (args[i].equals("-xml")) {
          docPreprocessor = new DocumentPreprocessor(args[0], DocType.XML);
          docPreprocessor.setElementDelimiter(args[++i]);
  
        } else if (args[i].equals("-encoding") && i+1 < args.length) {
          i++;
          encoding = args[i];
  
        } else if (args[i].equals("-printSentenceLengths")) {
          printSentenceLengths = true;
  
        } else if (args[i].equals("-suppressEscaping")) {
          String options = "ptb3Escaping=false";
          docPreprocessor.setTokenizerFactory(PTBTokenizer.factory(new WordTokenFactory(),options));
  
        } else if (args[i].equals("-tokenizerOptions") && i+1 < args.length) {
          i++;
          String options = args[i];
          docPreprocessor.setTokenizerFactory(PTBTokenizer.factory(new WordTokenFactory(),options));
  
        } else if (args[i].equals("-noTokenization")) {
          docPreprocessor.setTokenizerFactory(null);
          docPreprocessor.setSentenceDelimiter(System.getProperty("line.separator"));
  
        } else if (args[i].equals("-tag")) {
          docPreprocessor.setTagDelimiter(args[++i]);
  
        } else {
          System.err.println("Unknown option: " + args[i]);
        }
      }
  
      docPreprocessor.setEncoding(encoding);
  
      int numSents = 0;
      PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, encoding), true);
      for (List<HasWord> sentence : docPreprocessor) {
        numSents++;
        if (printSentenceLengths) {
          System.err.println("Length:\t" + sentence.size());
        }
        boolean printSpace = false;
        for (HasWord word : sentence) {
          if (printSpace) pw.print(" ");
          printSpace = true;
          pw.print(word.word());
        }
        pw.println();
      }
      pw.close();
      System.err.println("Read in " + numSents + " sentences.");
    }