semvec/pypi-packages huggingface dataset:
visualise-spacy-tree 0.0.6
Create dependency tree plots from SpaCy Doc objects

# visualise-spacy-tree

An alternative to [SpaCy's](https://spacy.io) [visualizer](https://spacy.io/usage/visualizers#dep), built on [GraphViz](https://graphviz.gitlab.io/). 

![Example plot image](https://github.com/cyclecycle/visualise-spacy-tree/blob/master/visualise_spacy_tree/example_plots/custom_plot.png)

## Prerequisites

- You need [GraphViz](https://graphviz.gitlab.io/download/) installed.

## Installation

With pip:

```bash
pip install visualise-spacy-tree
```

Or from source:

```bash
git clone https://github.com/cyclecycle/visualise-spacy-tree.git visualise_spacy_tree
cd visualise_spacy_tree
python setup.py install
```

## Usage

```python

# Parse a string to create SpaCy Doc object
import en_core_web_sm

text = 'Forging involves the shaping of metal using localized compressive forces.'

nlp = en_core_web_sm.load()
doc = nlp(text)

# Create the plot
import visualise_spacy_tree
png = visualise_spacy_tree.create_png(doc)

# Write it to a file
with open('parse_tree.png', 'wb') as f:
    f.write(png)

# If you're using Jupyter notebook, you can render it inline
from IPython.display import Image, display
display(Image(png))

# Override node attributes to customise the plot
from spacy.tokens import Token
Token.set_extension('plot', default={})  # Create a token underscore extension
for token in doc:
    node_label = '{0} [{1}])'.format(token.orth_, token.i)
    token._.plot['label'] = node_label
    if token.dep_ == 'ROOT':
        token._.plot['color'] = 'green'

'''
You can set any valid GraphViz dot attribute in 'plot'.
See GraphViz docs for reference of possible node attributes:
https://graphviz.gitlab.io/_pages/doc/info/attrs.html
'''

```

## Running the tests

Run 

```bash
pytest
```

from the root directory.

## Acknowledgements

Uses:

- [pydot](https://github.com/pydot/pydot)

## Contributions

Are welcome :)
ipypy 0.1.2
ipypy notebook format

# ipypy

    Store Jupyter Notebooks in a more repo and coding friendly way.

Have you ever noticed that a Jupuyter Notebook nowadays is a json file? Containing together the metadata of the notebook itself, the list of cells, and for each cell, not only the *source* (what was written on it), but also the *outputs*, and *metadata* for each cell.

This project attemps to propose an alternative for that. 

## How

You can pick between a SplitCodeManager, which stores each notebook in:
  * my_file.ipynb (the usual notebook file, but with source information extracted)
  * my_file.ipypy (a pure code file that stores only the actual source code)

Or, a SplitOutputManager, which stores each notebook in:
  * my_file.ipynb (the usual notebook file, but without the cells output)
  * my_file.nbout (a json file that stores only the outputs of each cell)


## Benefits

* You can now import your notebook from another file
* You can now use standard coding tools and practices for manipulating Notebooks code:
  * testing
  * import code defined in there
  * editable naturally by any editor
  * refactoring
  * tracking changes
  * ...
* The source code of your notebook, can be versioned in a repository, where diffs, and history is readable. Now makes sense. It's code.
* (Work In Progress) You can choose to simply ignore the metadata files (.ipynb) in the repository, or keep them versioned. It should be up to you.

## Warning

We are in beta. Once you open a notebook with this extension enabled, and later save it, your notebook will be saved in a format a bit incompatible.

## Installation

    $ pip install ipypy

You will also need to configure your jupyter so it uses `ipypy`, by editing your jupyter config file, or from command line

    $ jupyter lab --NotebookApp.contents_manager_class="ipypy.SplitCodeManager"