在标准答案与分词结果上执行评测

@param goldFile
@param predFile
@return
169411
public static Result evaluate(String goldFile, String predFile, String dictPath) throws IOException
    {
        IOUtil.LineIterator goldIter = new IOUtil.LineIterator(goldFile);
        IOUtil.LineIterator predIter = new IOUtil.LineIterator(predFile);
        CWSEvaluator evaluator = new CWSEvaluator(dictPath);
        while (goldIter.hasNext() && predIter.hasNext())
        {
            evaluator.compare(goldIter.next(), predIter.next());
        }
        return evaluator.getResult();
    }
156104
public static List<String> listObjectsInFile(@NonNull File f){
        Preconditions.checkState(f.exists(), "File must exist: %s", f);

        List<String> out = new ArrayList<>();
        try (ZipFile zipFile = new ZipFile(f)){

            Enumeration<? extends ZipEntry> entries = zipFile.entries();
            while(entries.hasMoreElements()){
                ZipEntry e = entries.nextElement();
                String name = e.getName();
                if(!e.isDirectory() && name.startsWith("objects/")){
                    String s = name.substring(8);
                    out.add(s);
                }
            }
            return out;
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }
497238
Path uploadToJobFolder(final File file) throws IOException {
    final Path source = new Path(file.getAbsolutePath());
    final Path destination = new Path(this.jobSubmissionDirectory + "/" + file.getName());
    LOG.log(Level.FINE, "Uploading {0} to {1}", new Object[]{source, destination});
    this.fileSystem.copyFromLocalFile(false, true, source, destination);
    return destination;
  }
1198465
public static File[] listFiles(final File f) {
        return AccessController.doPrivileged(new PrivilegedAction<File[]>() {
            @Override
            public File[] run() {
                return f.listFiles();
            }
        });
    }
1134108
static void splitByLine(final File file, final int numOfParts, final File destDir) throws UncheckedIOException {
        final long lineNumOfPart = estimateLineCount(file, 10000) / numOfParts;

        int index = file.getName().lastIndexOf('.');
        String prefix = file.getName().substring(0, index);
        String postfix = (index > 0) ? file.getName().substring(index) : "";

        final Holder<ZipFile> outputZipFile = new Holder<>();
        InputStream is = null;

        BufferedReader br = null;
        BufferedWriter bw = null;
        int fileSerNum = 1;

        try {
            is = openFile(outputZipFile, file);

            br = Objectory.createBufferedReader(is);

            String subFileNmae = destDir.getAbsolutePath() + IOUtil.FILE_SEPARATOR + prefix + "_" + StringUtil.padStart(N.stringOf(fileSerNum++), 4, '0')
                    + postfix;
            bw = Objectory.createBufferedWriter(new FileWriter(new File(subFileNmae)));

            int lineCounter = 0;
            String line = null;
            while ((line = br.readLine()) != null) {
                bw.write(line);
                bw.write(IOUtil.LINE_SEPARATOR);
                lineCounter++;

                if ((lineCounter % lineNumOfPart) == 0) {
                    if (bw != null) {
                        close(bw);
                        Objectory.recycle(bw);
                        bw = null;
                    }

                    subFileNmae = destDir.getAbsolutePath() + IOUtil.FILE_SEPARATOR + prefix + "_" + StringUtil.padStart(N.stringOf(fileSerNum++), 4, '0')
                            + postfix;
                    bw = Objectory.createBufferedWriter(new FileWriter(new File(subFileNmae)));
                }
            }

            if (bw != null) {
                close(bw);
                Objectory.recycle(bw);
                bw = null;
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        } finally {
            if (bw != null) {
                close(bw);
                Objectory.recycle(bw);
            }

            closeQuietly(is);
            close(outputZipFile.value());

            Objectory.recycle(br);
        }
    }
613594
@Override
  public void prefetchToken(final File tokenFile, final Props props, final Logger logger)
      throws HadoopSecurityManagerException {
    final String userToProxy = props.getString(JobProperties.USER_TO_PROXY);

    logger.info("Getting hadoop tokens based on props for " + userToProxy);
    doPrefetch(tokenFile, props, logger, userToProxy);
  }
415321
private static void addBundleFile(final Object bundlefile, final Set<Object> path,
            final ClassLoader classLoader, final ClasspathOrder classpathOrderOut, final ScanSpec scanSpec,
            final LogNode log) {
        // Don't get stuck in infinite loop
        if (bundlefile != null && path.add(bundlefile)) {
            // type File
            final Object basefile = ReflectionUtils.getFieldVal(bundlefile, "basefile", false);
            if (basefile != null) {
                boolean foundClassPathElement = false;
                for (final String fieldName : FIELD_NAMES) {
                    final Object fieldVal = ReflectionUtils.getFieldVal(bundlefile, fieldName, false);
                    foundClassPathElement = fieldVal != null;
                    if (foundClassPathElement) {
                        // We found the base file and a classpath element, e.g. "bin/"
                        classpathOrderOut.addClasspathEntry(basefile.toString() + "/" + fieldVal.toString(),
                                classLoader, scanSpec, log);
                        break;
                    }
                }

                if (!foundClassPathElement) {
                    // No classpath element found, just use basefile
                    classpathOrderOut.addClasspathEntry(basefile.toString(), classLoader, scanSpec, log);
                }

            }
            addBundleFile(ReflectionUtils.getFieldVal(bundlefile, "wrapped", false), path, classLoader,
                    classpathOrderOut, scanSpec, log);
            addBundleFile(ReflectionUtils.getFieldVal(bundlefile, "next", false), path, classLoader,
                    classpathOrderOut, scanSpec, log);
        }
    }
584589
public double[] evaluate(String testCorpus) throws IOException, ExecutionException, InterruptedException
    {
        Options options = parser.options;
        options.goldFile = testCorpus;
        File tmpTemplate = File.createTempFile("pred-" + new Date().getTime(), ".conll");
        tmpTemplate.deleteOnExit();
        options.predFile = tmpTemplate.getAbsolutePath();
        options.outputFile = options.predFile;
        File scoreFile = File.createTempFile("score-" + new Date().getTime(), ".txt");
        scoreFile.deleteOnExit();
        parser.parseConllFile(testCorpus, options.outputFile, options.rootFirst, options.beamWidth, true,
                              options.lowercase, 1, false, scoreFile.getAbsolutePath());
        return Evaluator.evaluate(options.goldFile, options.predFile, options.punctuations);
    }
1347548
public long writeBody(File destFile, StreamProgress streamProgress) {
		if (null == destFile) {
			throw new NullPointerException("[destFile] is null!");
		}
		if (destFile.isDirectory()) {
			// 从头信息中获取文件名
			String fileName = getFileNameFromDisposition();
			if (StrUtil.isBlank(fileName)) {
				final String path = this.httpConnection.getUrl().getPath();
				// 从路径中获取文件名
				fileName = StrUtil.subSuf(path, path.lastIndexOf('/') + 1);
				if (StrUtil.isBlank(fileName)) {
					// 编码后的路径做为文件名
					fileName = URLUtil.encodeQuery(path, CharsetUtil.CHARSET_UTF_8);
				}
			}
			destFile = FileUtil.file(destFile, fileName);
		}

		return writeBody(FileUtil.getOutputStream(destFile), true, streamProgress);
	}
96457
public static DownloadResponse exportSpreadsheet(Drive drive, File file) throws IOException {
    return exportSpreadsheet(drive, file.getId());
  }
687280
function getPublishFile(selectedFile) {
        console.log('你需要发布文件如下：');
        
        var files = [];
        selectedFile.forEach(function(file, idx) {
            console.log('  [' + (idx + 1) + ']' + file);
            files.push(file);
        });
        
        prepareBatchPubFiles(awpConfig, pubConfig, files);

    }
350009
public JavaFileObject useSource(JavaFileObject file) {
        JavaFileObject prev = (source == null ? null : source.getFile());
        source = getSource(file);
        return prev;
    }
525587
private static void doCopyFile(File srcFile, File destFile) throws IOException
   {
      if (destFile.exists() && destFile.isDirectory())
      {
         throw new IOException("Destination '" + destFile + "' exists but is a directory");
      }

      FileInputStream fis = null;
      FileOutputStream fos = null;
      FileChannel input = null;
      FileChannel output = null;
      try
      {
         fis = new FileInputStream(srcFile);
         fos = new FileOutputStream(destFile);
         input = fis.getChannel();
         output = fos.getChannel();
         long size = input.size();
         long pos = 0;
         long count = 0;
         while (pos < size)
         {
            count = (size - pos) > FIFTY_MB ? FIFTY_MB : (size - pos);
            pos += output.transferFrom(input, pos, count);
         }
      }
      finally
      {
         Streams.closeQuietly(output);
         Streams.closeQuietly(fos);
         Streams.closeQuietly(input);
         Streams.closeQuietly(fis);
      }

      if (srcFile.length() != destFile.length())
      {
         throw new IOException("Failed to copy full contents from '" +
                  srcFile + "' to '" + destFile + "'");
      }
   }
1104775
public static ArrayList<String> getFilteredLinesFromFile(final String fileName,
                                                           final String filter,
                                                           final String removeBeforeToken,
                                                           final String removeAfterToken) throws IOException{
    final ArrayList<String> filteredLines = new ArrayList<>();
    try (final BufferedReader in = new BufferedReader(
            new InputStreamReader(new FileInputStream(fileName), StandardCharsets.UTF_8))) {
      String line = "";
      while ((line = in.readLine()) != null) {
        if (line.trim().length() == 0) {
          continue;
        }
        if (line.contains(filter)) {
          String trimedLine;
          if (removeBeforeToken != null) {
            final String[] p = line.split(removeBeforeToken);
            if (p.length > 1) {
              trimedLine = p[p.length-1];
            } else {
              trimedLine = line.trim();
            }
          } else {
            trimedLine = line.trim();
          }
          if (removeAfterToken != null) {
            final String[] p = trimedLine.split(removeAfterToken);
            if (p.length > 1) {
              trimedLine = p[0];
            }
          }
          filteredLines.add(trimedLine);
        }
      }
    }
    return filteredLines;
  }
273262
@Override
	public List<Sentence> readFile(String datafile){
		try{
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					new FileInputStream(datafile), "UTF-8"));
			
			String line = null;
			List<Sentence> data = new ArrayList<Sentence>();
			
			while ((line = reader.readLine()) != null){				
				Sentence sentence = new Sentence();
				
				if (line.startsWith("#"))
					continue;
				
				StringTokenizer tk = new StringTokenizer(line, " ");	
				while (tk.hasMoreTokens()){
					String word = "", tag = null;
					if (!isTrainReading){
						String token = tk.nextToken();
						word = token;
						sentence.addTWord(word, tag);
					}
					else {
						String token = tk.nextToken();
						for (int i = 0; i < tags.length; ++i){
							String labelPart = "/" + tags[i];
							if (token.endsWith(labelPart)){
								word = token.substring(0, token.length() - labelPart.length());
								tag = tags[i];
								break;
							}
						}
						sentence.addTWord(word, tag);
					}
				}				
				data.add(sentence);
			}
			reader.close();
			return data;
		}
		catch (Exception e){
			System.out.println(e.getMessage());
			return new ArrayList<Sentence>(); // empty array
		}
	}
687928
public List<Long> searchBigFile(File f, byte[] searchBytes, OnProgressListener listener) {

		this.onRealtimeResultListener = null;
		this.onProgressListener = listener;

		int numOfThreadsOptimized = (int) (f.length() / (long) blockSize);

		if (numOfThreadsOptimized == 0) {
			numOfThreadsOptimized = 1;
		}

		return searchBigFile(f, searchBytes, numOfThreadsOptimized, this.useOptimization, 0);
	}
564650
public static void processFile(String infile, String outfile,String delimer,int tagnum) throws IOException {
		BufferedReader in = new BufferedReader(new UnicodeReader(new FileInputStream(infile), "utf8"));
		BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(
				outfile), "utf8"));
		String line = null;
		while ((line = in.readLine()) != null) {
			line = line.trim();
			String newline;			
			newline= genSegSequence(line,delimer,tagnum);
			out.write(newline);
			//			out.newLine();
		}
		in.close();
		out.close();

	}