Skip to content

visualize_spans function + manual argument + docstrings#37

Merged
pmbaumgartner merged 9 commits intomasterfrom
spans-displacy
Jun 14, 2022
Merged

visualize_spans function + manual argument + docstrings#37
pmbaumgartner merged 9 commits intomasterfrom
spans-displacy

Conversation

@pmbaumgartner
Copy link
Copy Markdown
Contributor

Adds a visualize_spans function for using the span visualization in displaCy.

I made a few choices that may need justification:

  • Even though spans_key is part of the options passed to displaCy, it feels critical enough to pass as an argument to visualize_spans rather than as a key/value in a dict to displacy_options - but we can obviously undo this.
  • I didn't include the span viz in the "display everything" visualize function because none of the base models will have labeled spans in them, so it wouldn't display anything useful.
  • Compared to visualize_ner:
    • I removed the manual argument because there's no such option for that with displaCy for spans
    • There's no label filtering/selection with spans, so all labels will be displayed for spans within a span_key. This removes the keys and labels args.

Extra:

  • Also added a missing docstring for the show_table argument on visualize_ner (as well as visualize_spans)

Open questions:

  • Is there a script to generate the nice readme.md documentation so we can include the new function?
  • I'm not totally sure what needs to happen for a release, but I'm happy to help do whatever needs to be done!

@pmbaumgartner pmbaumgartner changed the title visualize_spans function visualize_spans function + manual argument + docstrings Jun 10, 2022
@pmbaumgartner
Copy link
Copy Markdown
Contributor Author

I've added a few more updates, so the name of this branch is a bit of misnomer now.

I've updated visualize_parser and visualize_spans to take an argument manual so that they can all take data in the format described here: https://spacy.io/usage/visualizers#manual-usage

I've also updated the docstrings to include this argument, as well as added the args to the docstrings for visualize_parser.

Copy link
Copy Markdown

@rmitsch rmitsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Only nitpicking here.

@pmbaumgartner
Copy link
Copy Markdown
Contributor Author

Some smaller updates after testing out locally a bit more:

1️⃣ Added a very simple example app.
image

2️⃣ Added an exception catch if they have a version of spaCy before spans were supported in displaCy.

ValueError: 'visualize_spans' requires spacy>=3.3.0

3️⃣ Updated the README with a visualize_spans example and documentation.

@pmbaumgartner pmbaumgartner merged commit d1fd8ea into master Jun 14, 2022
@svlandeg svlandeg deleted the spans-displacy branch June 15, 2022 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants