diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-08-26 10:03:20 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-08-26 10:03:20 +0200 |
commit | 7d2cfad929be333a6a98e33b6c6344e1b29a5713 (patch) | |
tree | f3a7732370acbfe0e2d8104b31d82e1f592379a1 /searchlib | |
parent | 727ae90506e72ed0a6695e2d7cb5c719f0152842 (diff) |
Strip last names
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java index 827b1911369..b1714b49256 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java @@ -6,9 +6,7 @@ import com.google.common.collect.ImmutableMap; import com.yahoo.path.Path; import java.io.File; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; import java.util.Optional; /** @@ -71,11 +69,20 @@ public class ImportedModels { return importedModels.values(); } - private static String toName(File modelPath) { - String localPath = concatenateAfterModelsDirectory(Path.fromString(modelPath.toString())); + private static String toName(File modelFile) { + Path modelPath = Path.fromString(modelFile.toString()); + if (modelFile.isFile()) + modelPath = stripFileEnding(modelPath); + String localPath = concatenateAfterModelsDirectory(modelPath); return localPath.replace('.', '_'); } + private static Path stripFileEnding(Path path) { + int dotIndex = path.last().lastIndexOf("."); + if (dotIndex <= 0) return path; + return path.withLast(path.last().substring(0, dotIndex)); + } + private static String concatenateAfterModelsDirectory(Path path) { boolean afterModels = false; StringBuilder result = new StringBuilder(); |