mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-24 21:29:00 +00:00

Look, this will make the git history look funny, but trimming unnecessary depth from the source tree is a very necessary sanity-preserving measure when dealing with a super-modularized codebase like this one. While it makes the project configuration a bit less conventional, it will save you several clicks every time you jump between modules. Which you'll do a lot, because it's *modul*ar. The src/main/java convention makes a lot of sense for a non-modular project though. This ain't that.
39 lines
1.3 KiB
Java
39 lines
1.3 KiB
Java
package nu.marginalia.util;
|
|
|
|
import nu.marginalia.LanguageModels;
|
|
import nu.marginalia.WmsaHome;
|
|
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.util.Optional;
|
|
|
|
public class TestLanguageModels {
|
|
private static final Path LANGUAGE_MODELS_DEFAULT = WmsaHome.getHomePath().resolve("model");
|
|
|
|
public static Path getLanguageModelsPath() {
|
|
final Path languageModelsHome = Optional.ofNullable(System.getenv("LANGUAGE_MODELS_HOME"))
|
|
.map(Path::of)
|
|
.orElse(LANGUAGE_MODELS_DEFAULT);
|
|
|
|
if (!Files.isDirectory(languageModelsHome)) {
|
|
throw new IllegalStateException("Could not find $LANGUAGE_MODELS_HOME, see doc/language-models.md");
|
|
}
|
|
return languageModelsHome;
|
|
}
|
|
|
|
public static LanguageModels getLanguageModels() {
|
|
|
|
var languageModelsHome = getLanguageModelsPath();
|
|
|
|
return new LanguageModels(
|
|
languageModelsHome.resolve("ngrams.bin"),
|
|
languageModelsHome.resolve("tfreq-new-algo3.bin"),
|
|
languageModelsHome.resolve("opennlp-sentence.bin"),
|
|
languageModelsHome.resolve("English.RDR"),
|
|
languageModelsHome.resolve("English.DICT"),
|
|
languageModelsHome.resolve("opennlp-tokens.bin"),
|
|
languageModelsHome.resolve("lid.176.ftz")
|
|
);
|
|
}
|
|
}
|