Skip to main content

Visualization package for Spark NLP

Project description

spark-nlp-display

A library for the simple visualization of different types of Spark NLP annotations.

Supported Visualizations:

  • Dependency Parser
  • Named Entity Recognition
  • Entity Resolution
  • Relation Extraction
  • Assertion Status

Complete Tutorial

Open In Colab

https://github.com/JohnSnowLabs/spark-nlp-display/blob/main/tutorials/Spark_NLP_Display.ipynb

Requirements

  • spark-nlp
  • ipython
  • svgwrite
  • pandas
  • numpy

Installation

pip install spark-nlp-display

How to use

Dependency Parser

from sparknlp_display import DependencyParserVisualizer

dependency_vis = DependencyParserVisualizer()

dependency_vis.display(pipeline_result[0], #should be the results of a single example, not the complete dataframe.
                       pos_col = 'pos', #specify the pos column
                       dependency_col = 'dependency', #specify the dependency column
                       dependency_type_col = 'dependency_type' #specify the dependency type column
                       )

Named Entity Recognition

from sparknlp_display import NerVisualizer

ner_vis = NerVisualizer()

ner_vis.display(pipeline_result[0], #should be the results of a single example, not the complete dataframe
                    label_col='entities', #specify the entity column
                    document_col='document' #specify the document column (default: 'document')
                    labels=['PER'] #only allow these labels to be displayed. (default: [] - all labels will be displayed)
                    )

## To set custom label colors:
ner_vis.set_label_colors({'LOC':'#800080', 'PER':'#77b5fe'}) #set label colors by specifying hex codes

Entity Resolution

from sparknlp_display import EntityResolverVisualizer

er_vis = EntityResolverVisualizer()

er_vis.display(pipeline_result[0], #should be the results of a single example, not the complete dataframe
               label_col='entities', #specify the ner result column
               resolution_col = 'resolution'
               document_col='document' #specify the document column (default: 'document')
               )

## To set custom label colors:
er_vis.set_label_colors({'TREATMENT':'#800080', 'PROBLEM':'#77b5fe'}) #set label colors by specifying hex codes

Relation Extraction

from sparknlp_display import RelationExtractionVisualizer

re_vis = RelationExtractionVisualizer()

re_vis.display(pipeline_result[0], #should be the results of a single example, not the complete dataframe
               relation_col = 'relations', #specify relations column
               document_col = 'document', #specify document column
               show_relations=True #display relation names on arrows (default: True)
               )

Assertion Status

from sparknlp_display import AssertionVisualizer

assertion_vis = AssertionVisualizer()

assertion_vis.display(pipeline_result[0], 
                      label_col = 'entities', #specify the ner result column
                      assertion_col = 'assertion' #specify assertion column
                      document_col = 'document' #specify the document column (default: 'document')
                      )

## To set custom label colors:
assertion_vis.set_label_colors({'TREATMENT':'#008080', 'problem':'#800080'}) #set label colors by specifying hex codes

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spark-nlp-display-1.1.tar.gz (79.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spark_nlp_display-1.1-py3-none-any.whl (93.8 kB view details)

Uploaded Python 3

File details

Details for the file spark-nlp-display-1.1.tar.gz.

File metadata

  • Download URL: spark-nlp-display-1.1.tar.gz
  • Upload date:
  • Size: 79.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for spark-nlp-display-1.1.tar.gz
Algorithm Hash digest
SHA256 144a28d1fb00fc36f8cd286ea0e3b993c53a6440a1eaf4b4496cff11bd6df4a9
MD5 071460ae3d3f6419e28928b7eaeef41b
BLAKE2b-256 f60a9e2c2aa1ec9dd9e7452c11333d855589c0405025e461b016131c9b2936cf

See more details on using hashes here.

File details

Details for the file spark_nlp_display-1.1-py3-none-any.whl.

File metadata

  • Download URL: spark_nlp_display-1.1-py3-none-any.whl
  • Upload date:
  • Size: 93.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for spark_nlp_display-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d08d5fc05222f5cb9313550c023e5521f7bc32a747d44c13a3b329d22b3c454
MD5 3f318a9f69d1b6a295ea2b8216fddbd0
BLAKE2b-256 6f8c21d3a78b2f46a112e1d5215360c29760e7b34f383161b2288ffc7c95d834

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page