medkit.text.ner.duckling_matcher#

Classes:

DucklingMatcher(output_label, version[, ...])

Entity annotator using Duckling (https://github.com/facebook/duckling).

class DucklingMatcher(output_label, version, url='http://localhost:8000', locale='fr_FR', dims=None, attrs_to_copy=None, uid=None)[source]#

Entity annotator using Duckling (https://github.com/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>

Instantiate the Duckling matcher

Parameters
  • version (str) – Version of the Duckling server.

  • output_label (str) – Label to use for attributes created by this annotator.

  • url (str) – URL of the server. Defaults to “http://localhost:8000

  • locale (str) – Language flag of the text to parse following ISO-639-1 standard, e.g. “fr_FR”

  • dims (Optional[List[str]]) – List of dimensions to extract. If None, all available dimensions will be extracted.

  • attrs_to_copy (Optional[List[str]]) – Labels of the attributes that should be copied from the source segment to the created entity. Useful for propagating context attributes (negation, antecendent, etc)

Methods:

run(segments)

Return entities for each match in segments

set_prov_tracer(prov_tracer)

Enable provenance tracing.

Attributes:

description

Contains all the operation init parameters.

run(segments)[source]#

Return entities for each match in segments

Parameters

segments (List[Segment]) – List of segments into which to look for matches

Return type

List[Entity]

Returns

entities (List[Entity]) – Entities found in segments

property description: medkit.core.operation_desc.OperationDescription#

Contains all the operation init parameters.

Return type

OperationDescription

set_prov_tracer(prov_tracer)#

Enable provenance tracing.

Parameters

prov_tracer (ProvTracer) – The provenance tracer used to trace the provenance.