code: private static void extractText(Path file, BufferedWriter writer, String separator, boolean includePhrase){
          try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file.toFile()),"utf-8"));){
              String line;
              while( (line = reader.readLine()) != null ){
                  //去除首尾空白字符
                  line = line.trim();
                  //忽略空行
                  if(!"".equals(line)){
                      //词和词之间以空格隔开
                      String[] words = line.split("\\s+");
                      if(words == null){
                          //忽略不符合规范的行
                          continue;
                      }
                      StringBuilder phrase = new StringBuilder();
                      int phraseCount=0;
                      boolean find=false;
                      for(String word : words){
                          String[] attr = word.split("/");
                          if(attr == null || attr.length < 1){
                              //忽略不符合规范的词
                              continue;
                          }
                          if(attr[0].trim().startsWith("[")){
                              find = true;
                          }                        
                          //去掉[和]
                          String item = attr[0].replace("[", "").replace("]", "").trim();
                          writer.write(item+separator);
                          if(find){
                              phrase.append(item);
                              phraseCount++;
                          }
                          //短语标注错误
                          if(phraseCount > 10){
                              find = false;
                              phraseCount = 0;
                              phrase.setLength(0);
                          }
                          if(find && attr.length > 1 && attr[1].trim().endsWith("]")){
                              find = false;
                              if(includePhrase){
                                  writer.write(phrase.toString()+separator);
                              }
                              phrase.setLength(0);
                          }
                          //词数目
                          WORD_COUNT.incrementAndGet();
                          //字符数目
                          CHAR_COUNT.addAndGet(item.length());
                      }
                      //换行
                      writer.write("\n");
                  }
              }
          }catch(Exception e){
              LOGGER.info("从语料库 "+file+" 中抽取文本失败：", e);
          }        
      }
docs: 从语料库中抽取文本保存到指定文件
  @param file 语料库
  @param writer 输出文件
  @param separator 词与词的分隔符
  @param includePhrase 是否包含识别出的短语