Skip to content

Commit

Permalink
fix unnecessary onnx model file download (#2191)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurChen189 authored Sep 9, 2023
1 parent d83aa5b commit ae6ff62
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/io/anserini/search/query/QueryEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,23 @@ public abstract class QueryEncoder {

static protected Path getModelPath(String modelName, String modelURL) throws IOException {
File modelFile = new File(getCacheDir(), modelName);
FileUtils.copyURLToFile(new URL(modelURL), modelFile);
if (!modelFile.exists()) {
System.out.println("Downloading model");
FileUtils.copyURLToFile(new URL(modelURL), modelFile);
} else{
System.out.println("Model already exists");
}
return modelFile.toPath();
}

static protected Path getVocabPath(String vocabName, String vocabURL) throws IOException {
File vocabFile = new File(getCacheDir(), vocabName);
FileUtils.copyURLToFile(new URL(vocabURL), vocabFile);
if (!vocabFile.exists()) {
System.out.println("Downloading vocab");
FileUtils.copyURLToFile(new URL(vocabURL), vocabFile);
} else{
System.out.println("Vocab already exists");
}
return vocabFile.toPath();
}

Expand Down

0 comments on commit ae6ff62

Please sign in to comment.