def _download_model(self) -> None: """Interface with the `stanza` model downloader.""" if not self.interactive: if not self.silent: print( f"CLTK message: Going to download required Stanza models to ``{self.model_path}`` ..." ) # pragma: no cover stanza.download(lang=self.stanza_code, package=self.treebank) else: print( # pragma: no cover "CLTK message: This part of the CLTK depends upon the Stanza NLP library." ) # pragma: no cover dl_is_allowed = query_yes_no( f"CLTK message: Allow download of Stanza models to ``{self.model_path}``?" ) # type: bool if dl_is_allowed: stanza.download(lang=self.stanza_code, package=self.treebank) else: raise CLTKException( f"Download of necessary Stanza model declined for '{self.language}'. Unable to continue with Stanza's processing." ) # if file model still not available after attempted DL, then raise error if not file_exists(self.model_path): raise FileNotFoundError( "Missing required models for ``stanza`` at ``{0}``.".format( self.model_path ) )
def _is_model_present(self) -> bool: """Checks if the model is already downloaded. >>> stanza_wrapper = StanzaWrapper(language='grc', stanza_debug_level="INFO") >>> stanza_wrapper._is_model_present() True """ if file_exists(self.model_path): return True return False