msfroh commented on code in PR #14198: URL: https://github.com/apache/lucene/pull/14198#discussion_r1945713513
########## lucene/analysis/opennlp/build.gradle: ########## @@ -26,3 +26,33 @@ dependencies { moduleTestImplementation project(':lucene:test-framework') } + +ext { + testModelDataDir = file('src/tools/test-model-data') + testsUserDir = file('src/test-files') + testModelDir = file("${testsUserDir}/org/apache/lucene/analysis/opennlp") +} + +tasks.register('trainTestModels') { + description = 'Train all small test models for unit tests' + doLast { + mkdir testModelDir + trainModel('SentenceDetectorTrainer', 'en', 'sentences.txt', 'en-test-sent.bin') + trainModel('TokenizerTrainer', 'en', 'tokenizer.txt', 'en-test-tokenizer.bin') + trainModel('POSTaggerTrainer', 'en', 'pos.txt', 'en-test-pos-maxent.bin') + trainModel('ChunkerTrainerME', 'en', 'chunks.txt', 'en-test-chunker.bin') + trainModel('TokenNameFinderTrainer', 'en', 'ner.txt', 'en-test-ner.bin', ['-params', 'ner_TrainerParams.txt']) + trainModel('LemmatizerTrainerME', 'en', 'lemmas.txt', 'en-test-lemmatizer.bin') + } +} + +def trainModel(String command, String lang, String data, String model, List extraArgs = []) { + javaexec { + classpath = sourceSets.main.compileClasspath + mainClass = 'opennlp.tools.cmdline.CLI' + workingDir = testModelDataDir + args = [command, '-lang', lang, '-data', data, '-model', "${testModelDir}/${model}"] + extraArgs + } +} + +tasks.register('regenerate') { dependsOn 'trainTestModels' } Review Comment: Nope -- I checked by running the `trainTestModels` task again and the model files all had *something* change. So, I'm going to remove this line and we can stick to manual training as needed. 👍 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org