Skip to content

Commit

Permalink
Decide whether or not to use lemma_classifier based on charlm args, i…
Browse files Browse the repository at this point in the history
…f lemma_classifier is not specifically set. Pass along the charlm args to the lemma classifier as well
  • Loading branch information
AngledLuffa committed Dec 22, 2024
1 parent 82c70f6 commit 6529df0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions stanza/utils/training/run_lemma.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
def add_lemma_args(parser):
add_charlm_args(parser)

parser.add_argument('--no_lemma_classifier', dest='lemma_classifier', action='store_false', default=True,
help="Don't use the lemma classifier datasets. Default is to build lemma classifier as part of the original lemmatizer")
parser.add_argument('--lemma_classifier', dest='lemma_classifier', action='store_true', default=None,
help="Don't use the lemma classifier datasets. Default is to build lemma classifier as part of the original lemmatizer if the charlm is used")
parser.add_argument('--no_lemma_classifier', dest='lemma_classifier', action='store_false',
help="Don't use the lemma classifier datasets. Default is to build lemma classifier as part of the original lemmatizer if the charlm is used")

def build_model_filename(paths, short_name, command_args, extra_args):
"""
Expand Down Expand Up @@ -148,10 +150,13 @@ def run_treebank(mode, paths, treebank, short_name,
logger.info("Running test lemmatizer for {} with args {}".format(treebank, test_args))
lemmatizer.main(test_args)

use_lemma_classifier = command_args.lemma_classifier and short_name in prepare_lemma_classifier.DATASET_MAPPING
use_lemma_classifier = command_args.lemma_classifier
if use_lemma_classifier is None:
use_lemma_classifier = command_args.charlm is not None
use_lemma_classifier = use_lemma_classifier and short_name in prepare_lemma_classifier.DATASET_MAPPING
if use_lemma_classifier and mode == Mode.TRAIN:
# TODO: pass along charlm args
lemma_classifier_args = [treebank]
lc_charlm_args = ['--no_charlm'] if command_args.charlm is None else ['--charlm', command_args.charlm]
lemma_classifier_args = [treebank] + lc_charlm_args
if command_args.force:
lemma_classifier_args.append('--force')
run_lemma_classifier.main(lemma_classifier_args)
Expand Down

0 comments on commit 6529df0

Please sign in to comment.