code: public static void load(String dir, List<String[]> sentences, List<PennTreebankPOS[]> labels) {
          List<File> files = new ArrayList<>();
          walkin(new File(dir), files);
  
          for (File file : files) {
              try {
                  FileInputStream stream = new FileInputStream(file);
                  BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
                  String line = null;
                  List<String> sent = new ArrayList<>();
                  List<PennTreebankPOS> label = new ArrayList<>();
                  while ((line = reader.readLine()) != null) {
                      line = line.trim();
                      if (line.isEmpty()) {
                          if (!sent.isEmpty()) {
                              sentences.add(sent.toArray(new String[sent.size()]));
                              labels.add(label.toArray(new PennTreebankPOS[label.size()]));
                              sent.clear();
                              label.clear();
                          }
                      } else if (!line.startsWith("===") && !line.startsWith("*x*")) {
                          String[] words = line.split("\\s");
                          for (String word : words) {
                              String[] w = word.split("/");
                              if (w.length == 2) {
                                  sent.add(w[0]);
                                  
                                  int pos = w[1].indexOf('|');
                                  String tag = pos == -1 ? w[1] : w[1].substring(0, pos);
                                  if (tag.equals("PRP$R")) tag = "PRP$";
                                  if (tag.equals("JJSS")) tag = "JJS";
                                  label.add(PennTreebankPOS.getValue(tag));
                              }
                          }
                      }
                  }
                  
                  if (!sent.isEmpty()) {
                      sentences.add(sent.toArray(new String[sent.size()]));
                      labels.add(label.toArray(new PennTreebankPOS[label.size()]));
                      sent.clear();
                      label.clear();
                  }
                  
                  reader.close();
              } catch (Exception e) {
                  logger.error("Failed to load training data {}", file, e);
              }
          }
      }
docs: Load training data from a corpora.
  @param dir a file object defining the top directory