medkit.text.spacy.displacy_utils
medkit.text.spacy.displacy_utils#
Functions:
|
Build data dict that can be passed to displacy.render() (with manual=True and style="ent") to vizualize entities of a document. |
|
Build data dict that can be passed to displacy.render() (with manual=True and style="ent") to vizualize entities. |
- medkit_doc_to_displacy(medkit_doc, segment_labels=None, segment_formatter=None, max_gap_length=3)[source]#
Build data dict that can be passed to displacy.render() (with manual=True and style=”ent”) to vizualize entities of a document.
- Parameters
medkit_doc (
TextDocument) – Document to visualize.segment_labels (
Optional[List[str]]) – Labels of segments to display. If None, all entities are displayed (but not segments).segment_formatter (
Optional[Callable[[Segment],str]]) – Optional function returning the text to display as label for a given segment. If None, the segment label will be used. Can be used for instance to display normalization information available in entity or segment attributes.max_gap_length (
int) – When cleaning up gaps in spans, spans around gaps smaller than max_gap_length will be merged. Cfclean_up_gaps_in_normalized_spans().
- Return type
Dict[str,Any]- Returns
Dict[str, Any] – Data to be passed to displacy.render() as docs argument (with manual=True and style=”ent”)
- segments_to_displacy(segments, raw_text, segment_formatter=None, max_gap_length=3)[source]#
Build data dict that can be passed to displacy.render() (with manual=True and style=”ent”) to vizualize entities.
- Parameters
segments (
List[Segment]) – Segments (and/or entities) to visualize in text context.raw_text (
str) – Initial document text from which entities where extracted and to which they spans refer (typically the text attribute of aTextDocument).segment_formatter (
Optional[Callable[[Segment],str]]) – Optional function returning the text to display as label for a given segment. If None, the segment label will be used. Can be used for instance to display normalization information available in entity or segment attributes.max_gap_length (
int) – When cleaning up gaps in spans, spans around gaps smaller than max_gap_length will be merged. Cfclean_up_gaps_in_normalized_spans().
- Return type
Dict[str,Any]- Returns
Dict[str, Any] – Data to be passed to displacy.render() as docs argument (with manual=True and style=”ent”)