14.5.4. crate_anon.nlp_manager.all_processors
crate_anon/nlp_manager/all_processors.py
Copyright (C) 2015, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
This file is part of CRATE.
CRATE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
CRATE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with CRATE. If not, see <https://www.gnu.org/licenses/>.
Factory functions to manage all NLP processor classes.
- crate_anon.nlp_manager.all_processors.all_crate_python_processors_nlprp_processor_info(sql_dialect: Optional[str] = None, extra_dict: Optional[Dict[str, Union[str, int, float, bool, None, Dict, List]]] = None) List[Union[str, int, float, bool, None, Dict, List]] [source]
Returns NLPRP processor information for all CRATE Python NLP processors.
- Parameters
sql_dialect – preferred SQL dialect for response, or
None
for a defaultextra_dict – extra dictionary to merge in for each processor
- Returns
list of processor information dictionaries
- Return type
list
- crate_anon.nlp_manager.all_processors.all_local_parser_classes() List[Type[crate_anon.nlp_manager.base_nlp_parser.BaseNlpParser]] [source]
Return all classes that are non-abstract subclasses of
crate_anon.nlp_manager.base_nlp_parser.BaseNlpParser
.Checks that they all have unique names in lower case.
- crate_anon.nlp_manager.all_processors.all_tablemaker_classes() List[Type[crate_anon.nlp_manager.base_nlp_parser.TableMaker]] [source]
Return all classes that are non-abstract subclasses of
crate_anon.nlp_manager.base_nlp_parser.TableMaker
.
- crate_anon.nlp_manager.all_processors.get_all_subclasses(cls: Type[object]) List[Type[object]] [source]
Returns all non-abstract subclasses of
cls
.- Parameters
cls – class into which to recurse
- Returns
list of classes
- crate_anon.nlp_manager.all_processors.get_nlp_parser_class(classname: str) Optional[Type[crate_anon.nlp_manager.base_nlp_parser.TableMaker]] [source]
Fetch an NLP parser class (not instance) by name. The match may be on either the class’s short name or the fully-qualified name, and is case-insensitive.
- Parameters
classname – the name of the NLP parser class
- Returns
the class, or
None
if there isn’t one with that name
- crate_anon.nlp_manager.all_processors.make_nlp_parser(classname: str, nlpdef: crate_anon.nlp_manager.nlp_definition.NlpDefinition, cfg_processor_name: str) crate_anon.nlp_manager.base_nlp_parser.TableMaker [source]
Fetch an NLP processor instance by name.
- Parameters
classname – the name of the processor
nlpdef – a
crate_anon.nlp_manager.nlp_definition.NlpDefinition
cfg_processor_name – the name (suffix) of a CRATE NLP config file section, passed to the NLP parser as we create it (for it to get extra config information if it wishes)
- Returns
an NLP processor instance whose class name matches (in case-insensitive fashion)
classname
.- Raises
ValueError –
- crate_anon.nlp_manager.all_processors.make_nlp_parser_unconfigured(classname: str, raise_if_absent: bool = True) Optional[crate_anon.nlp_manager.base_nlp_parser.TableMaker] [source]
Get a debugging (unconfigured) instance of an NLP parser.
- Parameters
classname – the name of the NLP parser class
raise_if_absent – raise
ValueError
if there is no match?
- Returns
the class, or
None
if there isn’t one with that name
- crate_anon.nlp_manager.all_processors.possible_local_processor_names() List[str] [source]
Returns all NLP processor names that can run locally.
- crate_anon.nlp_manager.all_processors.possible_local_processor_names_without_external_tools() List[str] [source]
Returns all NLP processor names for processors that don’t rely on external tools.