12.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: str | None = None, extra_dict: Dict[str, str | int | float | bool | None | Dict | List] | None = None) List[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
Nonefor 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[BaseNlpParser]][source]
Return all classes that are non-abstract subclasses of
crate_anon.nlp_manager.base_nlp_parser.BaseNlpParser.… but not test parsers.
Checks that they all have unique names in lower case.
- crate_anon.nlp_manager.all_processors.all_local_processor_classes_without_external_tools() List[Type[BaseNlpParser]][source]
Returns all NLP processor classes that don’t rely on external tools.
- crate_anon.nlp_manager.all_processors.all_nlp_processor_classes() List[Type[TableMaker]][source]
Returns all NLP processor classes.
- crate_anon.nlp_manager.all_processors.all_tablemaker_classes() List[Type[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) Type[TableMaker] | None[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
Noneif there isn’t one with that name
- crate_anon.nlp_manager.all_processors.make_nlp_parser(classname: str, nlpdef: NlpDefinition, cfg_processor_name: str) TableMaker[source]
Fetch an NLP processor instance by name.
- Parameters:
classname – the name of the processor
nlpdef – a
crate_anon.nlp_manager.nlp_definition.NlpDefinitioncfg_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.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.
- crate_anon.nlp_manager.all_processors.possible_processor_names_including_cloud() List[str][source]
Returns all NLP processor names.
- crate_anon.nlp_manager.all_processors.possible_processor_table() str[source]
Returns a pretty-formatted string containing a table of all NLP processors and their description (from their docstring).
- crate_anon.nlp_manager.all_processors.register_all_crate_python_processors_with_serverprocessor(set_parser: bool = True) None[source]
Somewhat ugly. Register all CRATE Python NLP processors with the ServerProcessor class.
See also crate_anon/nlp_webserver/procs.py, for a similar thing from JSON.
- Parameters:
set_parser – Set up a “free-floating” parser too?