Skip to content

Commit

Permalink
Fix NPE due to the missing initialisation of the configuration before…
Browse files Browse the repository at this point in the history
… instantiating the models #131
  • Loading branch information
lfoppiano committed Dec 9, 2021
1 parent c68dac1 commit 68e4808
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public void configure(Subparser subparser) {

@Override
protected void run(Bootstrap bootstrap, Namespace namespace, GrobidQuantitiesConfiguration configuration) throws Exception {
String configurationGrobidHome = configuration.getGrobidHome();
File grobidHomeOverride = namespace.get(GROBID_HOME_DIRECTORY);
initGrobidHome(configurationGrobidHome, grobidHomeOverride);
configuration.getModels().stream().forEach(GrobidProperties::addModel);

// we need to execute this after the system has been initialised, or it will crash looking for the wapiti models in the wrong location
Map<String, AbstractTrainer> trainerMap = new HashMap<>();
Expand All @@ -89,11 +93,6 @@ protected void run(Bootstrap bootstrap, Namespace namespace, GrobidQuantitiesCon
trainerMap.putIfAbsent("values", new ValueTrainer());
trainerMap.putIfAbsent("quantifiedObject", new QuantifiedObjectTrainer());

String configurationGrobidHome = configuration.getGrobidHome();
File grobidHomeOverride = namespace.get(GROBID_HOME_DIRECTORY);
initGrobidHome(configurationGrobidHome, grobidHomeOverride);
configuration.getModels().stream().forEach(GrobidProperties::addModel);

String modelName = namespace.get(MODEL_NAME);
String action = namespace.get(ACTION);
Boolean print = namespace.get(PRINT);
Expand Down

0 comments on commit 68e4808

Please sign in to comment.