code: def main():
      args = add_and_parse_args()
      root_dirpath: pathlib.Path = args.root_dirpath.resolve()
      test_fpath = root_dirpath / "test.txt"
      lang_identifier = textacy.lang_id.LangIdentifier(
          version=args.version, data_dir=root_dirpath
      )
  
      logging.info("training language identifier model ...")
      model = floret.train_supervised(
          str(root_dirpath / "train.txt"),
          dim=args.dim,
          minn=args.minn,
          maxn=args.maxn,
          wordNgrams=args.wordNgrams,
          lr=args.lr,
          loss=args.loss,
          epoch=args.epoch,
          thread=args.thread,
      )
      if args.cutoff:
          logging.info("compressing language identifier model ...")
          model.quantize(
              str(root_dirpath / "train.txt"),
              cutoff=args.cutoff,
              retrain=True,
              qnorm=True,
              dsub=2,
              verbose=True,
          )
  
      lang_identifier._model = model
      # lang_identifier.load_model()  # HACK! to skip training and just do eval
  
      eval_report = _evaluate_model(test_fpath, lang_identifier)
      print(eval_report)
  
      if args.save:
          lang_identifier.save_model()
  
file_path: textacy/scripts/train_lang_identifier_v3.py
imports: from __future__ import annotations
  import argparse
  import logging
  import pathlib
  import floret
  import sklearn.metrics
  import textacy
  import textacy.lang_id
label_desc: Use image node_id 1 for calling a global function with example usage: main() without return types