msfroh commented on code in PR #14198: URL: https://github.com/apache/lucene/pull/14198#discussion_r1945585486
########## 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: Ahh... the LLM that helped me to migrate the Ant build to Gradle (after I spent an hour trying to do it by hand) copied the regenerate task from this line: https://github.com/apache/lucene-solr/blob/releases/lucene-solr/8.11.2/lucene/analysis/opennlp/build.xml#L117 I *think* the output is deterministic, but will change when a) OpenNLP is upgraded again or b) someone updates the training files. Assuming neither of those happen very often (as has been the case recently), I think leaving it manual makes sense. -- 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