Coder Social home page Coder Social logo

natasha / ipymarkup Goto Github PK

View Code? Open in Web Editor NEW
134.0 6.0 29.0 897 KB

NER, syntax markup visualizations

License: MIT License

Jupyter Notebook 84.61% Python 15.30% Makefile 0.09%
jupyter jupyter-widget visualization python syntax-tree dependency-parser nlp ner

ipymarkup's Introduction

CI

Collection of NLP visualizations for NER and syntax tree markup. Similar to Spacy displaCy and displaCy ENT.

Install

ipymarkup supports Python 3.7+.

$ pip install ipymarkup

Usage

>>> from ipymarkup import show_span_ascii_markup, show_dep_ascii_markup

>>> text = 'В мероприятии примут участие не только российские учёные, но и зарубежные исследователи, в том числе, Крис Хелмбрехт - управляющий директор и совладелец креативного агентства Kollektiv (Германия, США), Ннека Угбома - руководитель проекта Mushroom works (Великобритания), Гергей Ковач - политик и лидер субкультурной партии «Dog with two tails» (Венгрия), Георг Жено - немецкий режиссёр, один из создателей экспериментального театра «Театр.doc», Театра им. Йозефа Бойса (Германия).'
>>> spans = [(102, 116, 'PER'), (186, 194, 'LOC'), (196, 199, 'LOC'), (202, 214, 'PER'), (254, 268, 'LOC'), (271, 283, 'PER'), (324, 342, 'ORG'), (345, 352, 'LOC'), (355, 365, 'PER'), (445, 455, 'ORG'), (456, 468, 'PER'), (470, 478, 'LOC')]
>>> show_span_ascii_markup(text, spans)

В мероприятии примут участие не только российские учёные, но и 
зарубежные исследователи, в том числе, Крис Хелмбрехт - управляющий 
                                       PER───────────               
директор и совладелец креативного агентства Kollektiv (Германия, США),
                                                       LOC─────  LOC  
 Ннека Угбома - руководитель проекта Mushroom works (Великобритания), 
 PER─────────                                        LOC───────────   
Гергей Ковач - политик и лидер субкультурной партии «Dog with two 
PER─────────                                         ORG──────────
tails» (Венгрия), Георг Жено - немецкий режиссёр, один из создателей 
─────   LOC────   PER───────                                         
экспериментального театра «Театр.doc», Театра им. Йозефа Бойса 
                                       ORG─────── PER───────── 
(Германия).
 LOC─────  

>>> words = ['В', 'советский', 'период', 'времени', 'число', 'ИТ', '-', 'специалистов', 'в', 'Армении', 'составляло', 'около', 'десяти', 'тысяч', '.']
>>> deps = [(2, 0, 'case'), (2, 1, 'amod'), (10, 2, 'obl'), (2, 3, 'nmod'), (10, 4, 'obj'), (7, 5, 'compound'), (5, 6, 'punct'), (4, 7, 'nmod'), (9, 8, 'case'), (4, 9, 'nmod'), (13, 11, 'case'), (13, 12, 'nummod'), (10, 13, 'nsubj'), (10, 14, 'punct')]
>>> show_dep_ascii_markup(words, deps)

        ┌──► В            case
        │ ┌► советский    amod
┌──────►└─└─ период       obl
│       └──► времени      nmod
│ ┌►┌─┌───── число        obj
│ │ │ │ ┌►┌─ ИТ           compound
│ │ │ │ │ └► -            punct
│ │ │ └►└─── специалистов nmod
│ │ │     ┌► в            case
│ │ └────►└─ Армении      nmod
└─└─┌─┌───── составляло   
    │ │ ┌──► около        case
    │ │ │ ┌► десяти       nummod
    │ └►└─└─ тысяч        nsubj
    └──────► .            punct

Documentation

For more examples and explanation see ipymarkup documentation.

Support

Development

Dev env

python -m venv ~/.venvs/natasha-ipymarkup
source ~/.venvs/natasha-ipymarkup/bin/activate

pip install -r requirements/dev.txt
pip install -e .

python -m ipykernel install --user --name natasha-ipymarkup

Lint + update docs

make lint
make exec-notebooks

Release

# Update setup.py version

git commit -am 'Up version'
git tag v0.9.0

git push
git push --tags

ipymarkup's People

Contributors

kuk avatar neilrickards avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ipymarkup's Issues

Entity names shrinks to the shortes entity in the group

Hi! I found some small bug.
Here is the example:

Top entity is short, so it's name. 3 other entities are pretty long, but their names are shrinked to the shortest (top) entity.
image

The same example with bigger line_gap:
image

If we make top entity longer all renders fine:
image

What expected to be correct behaviour: each name shrinkage corresponding to its entity length, not to the shortest entity in the group.
Thanks!

Error using python 3.8

Traceback (most recent call last):
File ".../...py", line 1, in
from ipymarkup import show_box_markup
File ".../.venv/lib/python3.8/site-packages/ipymarkup/init.py", line 2, in
from .markup import * # noqa
File ".../.venv/lib/python3.8/site-packages/ipymarkup/markup.py", line 6, in
from cgi import escape
ImportError: cannot import name 'escape' from 'cgi' (.../.pyenv/versions/3.8.1/lib/python3.8/cgi.py)

Source distribution for PyPI

Could you make a source distribution on PyPI? That would make it easier for my colleagues within Facebook to use and perhaps contribute improvements to your code. We have import tools that make this go smoothly for us, but we need a source distribution if possible, so that we can have a lot of clarity on exactly what we are using, and can be sure to be maximally helpful to the open source community.

I think this gist says how to make a source distribution for PyPI.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.