TextVisualizer — tidyX documentation

# TextVisualizer

class tidyX.text_visualizer.TextVisualizer
  static dependency_parse_visualizer_text(document: str, style: str = 'dep', jupyter: bool = True, model: str = 'es_core_news_sm') → Optional[str]

    Visualizes the dependency parse or entities of a given document using spaCy’s displacy visualizer.

    For additional visualizers and information, refer to: https://spacy.io/usage/visualizers

    Note: - Ensure the relevant spaCy model is downloaded, using:

    ``sh python -m spacy download <model_name> ``

    where <model_name> can be “es_core_news_sm”, “es_core_news_md”, “es_core_news_lg”, or “es_dep_news_trf”.

    - To visualize entities, use style=’ent’

    Args:

      document (str): The text document to be visualized. style (str, optional): The visualization style (‘dep’ for dependencies, ‘ent’ for entities). Defaults to ‘dep’. jupyter (bool, optional): Whether the visualization is intended for a Jupyter notebook. Defaults to True. model (str, optional): The spaCy language model to use. Defaults to ‘es_core_news_sm’.

    Returns:

      Optional[str]: A rendered HTML string representation of the visualization if not in a Jupyter environment; otherwise, None, as the visualization is directly displayed.

    Raises:

      ValueError: If the provided document is empty or not a string. ValueError: If an invalid style is provided.