medkit.text.ner.duckling_matcher#

Classes#

DucklingMatcher

Entity annotator using Duckling (facebook/duckling).

Module Contents#

class medkit.text.ner.duckling_matcher.DucklingMatcher(output_label: str, version: str, url: str = 'http://localhost:8000', locale: str = 'fr_FR', dims: list[str] | None = None, attrs_to_copy: list[str] | None = None, uid: str | None = None)#

Bases: medkit.core.text.NEROperation

Entity annotator using Duckling (facebook/duckling).

This annotator can parse several types of information in multiple languages:

amount of money, credit card numbers, distance, duration, email, numeral, ordinal, phone number, quantity, temperature, time, url, volume.

This annotator currently requires a Duckling Server running. The easiest method is to run a docker container :

>>> docker run --rm -d -p <PORT>:8000 --name duckling rasa/duckling:<TAG>

This command will start a Duckling server listening on port <PORT>. The version of the server is identified by <TAG>

init_args#
output_label: str#
version: str#
url: str#
locale: str#
dims: list[str] | None#
attrs_to_copy: list[str]#
run(segments: list[medkit.core.text.Segment]) list[medkit.core.text.Entity]#

Return entities for each match in segments.

Parameters:
segmentslist of Segment

List of segments into which to look for matches

Returns:
list of Entity

Entities found in segments

_find_matches_in_segment(segment: medkit.core.text.Segment) Iterator[medkit.core.text.Entity]#
_test_connection()#