morphkit.get_word_blocks

morphkit.get_word_blocks(word_beta: str, api_endpoint: str, language: str = 'greek', output: str = 'full', debug: bool = False, timeout: int | float | None = None, retry_attempts: int | None = None, retry_delay: float | None = None) str[source]

Retrieve the raw word blocks data for a given beta-code word from a Morpheus endpoint.

Args:

word_beta (str):

The input word in beta-code format to look up. Backslashes in the input string need to be escaped: e.g., ‘a)nh/r’ -> ‘a)nh/r'

api_endpoint (str):

IP adress & port of the Morpheus API endpoint (e.g., ‘192.168.0.5:1315’).

language (str):

Optional argument. Defaults to greek. Sets the language of the word to analyse. It can be set to greek or latin.

output {str}:

Optional argument. Defaults to full. Output format of the Analytic block. Either full for the internal database format, or compact for a brief output.

debug (bool):

Optional argument. Defaults to False. If set to True, prints the constructed URL and response size.

timeout (int|float|None):

Optional argument. Defaults to config.timeout. Timeout in seconds for the request.

retry_attempts (int):

Optional argument. Defaults to config.retry_attempts. Number of retries on timeout/connection errors.

retry_delay (float):

Optional argument. Defaults to config.retry_delay. Delay between retries in seconds.

Returns:

str:

The plain text response containing the word blocks for the requested beta-code form.

Raises (when debug is set to True):

ValueError:

The language parameter is invalid.

ValueError:

The api_endpoint parameter is malformed.

ValueError:

Invalid timeout and/or retry parameters.

ValueError:

Unknown output format.

requests.HTTPError:

HTTP request failed (non-2xx status code).

MorpheusTimeoutError:

Request timed out after all retries.

MorpheusConnectionError:

Connection failed after all retries.

MorpheusAPIError:

Error in API request.

Example:

api_endpoint = "10.10.0.10:1315"
blocs=morphkit.get_word_blocks('sune/rxomai', api_endpoint)