Пример #1
0
  public static void copyFileLazy(String source, String destination) throws IOException {

    String oldContent = null;
    try {
      oldContent = FileUtil.read(source);
    } catch (FileNotFoundException fnfe) {
      return;
    }

    String newContent = null;
    try {
      newContent = FileUtil.read(destination);
    } catch (FileNotFoundException fnfe) {
    }

    if (oldContent == null || !oldContent.equals(newContent)) {
      FileUtil.copyFile(source, destination);
    }
  }
Пример #2
0
  private Doc buildDoc(int x, File file) {
    double minScore = 0.05;
    String s = FileUtil.read(file);
    String[] arr = s.split("\n");
    WVTWordVector vector = service.getNativeVector(s);
    if (filter) {
      Map<String, Double> newMap = new HashMap<String, Double>();
      for (Map.Entry<String, Double> entry : vector.getTFIDFValues().entrySet()) {
        if (entry.getValue() < minScore) {
          newMap.put(entry.getKey(), 0D);
        }
      }
      double[] values = vector.getValues();
      for (int i = 0; i < values.length; i++) {
        if (values[i] < minScore) {
          values[i] = 0D;
        }
      }
    }

    return new Doc(vector, file, x, arr[2], arr[0], arr[1]);
  }