private static void analyzeCorpus(String zipFile, String output, final String separator, final boolean includePhrase) throws IOException{
        File outputFile = new File(output);
        //准备输出目录
        if(!outputFile.getParentFile().exists()){
            outputFile.getParentFile().mkdirs();
        }
        try (FileSystem fs = FileSystems.newFileSystem(Paths.get(zipFile), ExtractText.class.getClassLoader());
                BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile),"utf-8"));) {
            for(Path path : fs.getRootDirectories()){                
                LOGGER.info("处理目录："+path);
                Files.walkFileTree(path, new SimpleFileVisitor<Path>(){

                    @Override
                    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                        LOGGER.info("处理文件："+file);
                        // 拷贝到本地文件系统
                        Path temp = Paths.get("target/corpus-"+System.currentTimeMillis()+".txt");
                        Files.copy(file, temp, StandardCopyOption.REPLACE_EXISTING);
                        extractText(temp, writer, separator, includePhrase);
                        return FileVisitResult.CONTINUE;
                    }
                    
                });
            }
        }
    }
private static void analyzeCorpus ( String zipFile , String output , final String separator , final boolean includePhrase ) throws IOException { File outputFile = new File ( output ) ; if ( ! outputFile . getParentFile ( ) . exists ( ) ) { outputFile . getParentFile ( ) . mkdirs ( ) ; } try ( FileSystem fs = FileSystems . newFileSystem ( Paths . get ( zipFile ) , ExtractText . class . getClassLoader ( ) ) ; BufferedWriter writer = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( outputFile ) , "utf-8" ) ) ; ) { for ( Path path : fs . getRootDirectories ( ) ) { LOGGER . info ( "处理目录：" + path ) ; Files . walkFileTree ( path , new SimpleFileVisitor < Path > ( ) { @ Override public FileVisitResult visitFile ( Path file , BasicFileAttributes attrs ) throws IOException { LOGGER . info ( "处理文件：" + file ) ; Path temp = Paths . get ( "target/corpus-" + System . currentTimeMillis ( ) + ".txt" ) ; Files . copy ( file , temp , StandardCopyOption . REPLACE_EXISTING ) ; extractText ( temp , writer , separator , includePhrase ) ; return FileVisitResult . CONTINUE ; } } ) ; } } }
分析语料库
@param zipFile 压缩的语料库
@param output 保存抽取出的文本的文件路径
@param separator 词之间的分隔符
@param includePhrase 是否抽取短语
@throws IOException