14.6.9. crate_anon.nlp_webserver.server_processor

crate_anon/nlp_webserver/server_processor.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/>.


ServerProcessor class.

class crate_anon.nlp_webserver.server_processor.ServerProcessor(name: str, title: str, version: str, is_default_version: bool, description: str, schema_type: str = 'unknown', sql_dialect: str | None = None, tabular_schema: Dict[str, Any] | None = None, proctype: str | None = None)[source]

Adds extra information to crate_anon.nlprp.api.NlprpServerProcessor.

  • For ease of finding processor info based on name and version (alternative would be a dictionary in which the keys were name_version and the values were another dictionary with the rest of the info).

  • Also used as the client-side representation.

__init__(name: str, title: str, version: str, is_default_version: bool, description: str, schema_type: str = 'unknown', sql_dialect: str | None = None, tabular_schema: Dict[str, Any] | None = None, proctype: str | None = None) None[source]
classmethod get_processor(name: str, version: str = '') ServerProcessor[source]

Fetch a processor by name and (optionally) version.

Parameters:
  • name – requested processor name

  • version – (optional) requested processor version

Returns:

a Processor

Raises:
  • crate_anon.nlprp.errors.NlprpError

  • matches.

classmethod get_processor_from_id(processor_id: str) ServerProcessor[source]

Fetch a processor, from a processor ID (a string representing name and versio).

Parameters:

processor_id – string in the format name_version. The version part can’t contain an underscore, but the name can.

Returns:

a Processor

Raises:
  • crate_anon.nlprp.errors.NlprpError

  • matches.

classmethod get_processor_nlprp(requested_processor_dict: Dict[str, str | int | float | bool | None | Dict | List]) ServerProcessor[source]

Fetch a processor, from an NLPRP dictionary specifying it.

Parameters:

requested_processor_dict – part of an NLPRP request

Returns:

a Processor

Raises:
  • crate_anon.nlprp.errors.NlprpError

  • NlprpKeys.NAME` key is missing or no processor matches

set_parser() None[source]

Sets ‘self.parser’ to an instance of a subclass of ‘BaseNlpParser’ not bound to any nlpdef or cfgsection, unless self.proctype is GATE (in which case, do nothing).