Skip to content

Latest commit

 

History

History
146 lines (131 loc) · 5.96 KB

en.md

File metadata and controls

146 lines (131 loc) · 5.96 KB

Syntax analysis by deplacy

Usage with Camphr-Udify

>>> import spacy
>>> nlp=spacy.load("en_udify")
>>> doc=nlp("I saw a horse yesterday which had no name.")
>>> import deplacy
>>> deplacy.render(doc)
I         PRON  <══════════════╗   nsubj
saw       VERB  ═══════════╗═╗═╝═╗ root
a         DET   <════════╗ ║ ║   ║ det
horse     NOUN  ═══════╗═╝<╝ ║   ║ obj
yesterday NOUN  <══════║═════╝   ║ obl:tmod
which     PRON  <════╗ ║         ║ nsubj
had       VERB  ═══╗═╝<╝         ║ acl:relcl
no        DET   <╗ ║             ║ det
name      NOUN  ═╝<╝             ║ obj
.         PUNCT <════════════════╝ punct

Usage with Stanza

>>> import stanza
>>> nlp=stanza.Pipeline("en")
>>> doc=nlp("I saw a horse yesterday which had no name.")
>>> import deplacy
>>> deplacy.render(doc)
I         PRON  <══════════════╗   nsubj
saw       VERB  ═══════════╗═╗═╝═╗ root
a         DET   <════════╗ ║ ║   ║ det
horse     NOUN  ═══════╗═╝<╝ ║   ║ obj
yesterday NOUN  <══════║═════╝   ║ obl:tmod
which     PRON  <════╗ ║         ║ nsubj
had       VERB  ═══╗═╝<╝         ║ acl:relcl
no        DET   <╗ ║             ║ det
name      NOUN  ═╝<╝             ║ obj
.         PUNCT <════════════════╝ punct

Usage with UDPipe 2

>>> def nlp(t):
...   import urllib.request,urllib.parse,json
...   with urllib.request.urlopen("https://lindat.mff.cuni.cz/services/udpipe/api/process?model=en&tokenizer&tagger&parser&data="+urllib.parse.quote(t)) as r:
...     return json.loads(r.read())["result"]
...
>>> doc=nlp("I saw a horse yesterday which had no name.")
>>> import deplacy
>>> deplacy.render(doc)
I         PRON  <══════════════╗   nsubj
saw       VERB  ═══════════╗═╗═╝═╗ root
a         DET   <════════╗ ║ ║   ║ det
horse     NOUN  ═══════╗═╝<╝ ║   ║ obj
yesterday NOUN  <══════║═════╝   ║ obl:tmod
which     PRON  <════╗ ║         ║ nsubj
had       VERB  ═══╗═╝<╝         ║ acl:relcl
no        DET   <╗ ║             ║ det
name      NOUN  ═╝<╝             ║ obj
.         PUNCT <════════════════╝ punct

Usage with NLP-Cube

>>> from cube.api import Cube
>>> nlp=Cube()
>>> nlp.load("en")
>>> doc=nlp("I saw a horse yesterday which had no name.")
>>> import deplacy
>>> deplacy.render(doc)
I         PRON  <══════════════╗   nsubj
saw       VERB  ═══════════╗═╗═╝═╗ root
a         DET   <════════╗ ║ ║   ║ det
horse     NOUN  ═══════╗═╝<╝ ║   ║ obj
yesterday NOUN  <══════║═════╝   ║ obl:tmod
which     PRON  <════╗ ║         ║ nsubj
had       VERB  ═══╗═╝<╝         ║ acl:relcl
no        DET   <╗ ║             ║ det
name      NOUN  ═╝<╝             ║ obj
.         PUNCT <════════════════╝ punct

Usage with Trankit

>>> import trankit
>>> nlp=trankit.Pipeline("english")
>>> doc=nlp("I saw a horse yesterday which had no name.")
>>> import deplacy
>>> deplacy.render(doc)
I         PRON  <══════════════╗   nsubj
saw       VERB  ═══════════╗═╗═╝═╗ root
a         DET   <════════╗ ║ ║   ║ det
horse     NOUN  ═══════╗═╝<╝ ║   ║ obj
yesterday NOUN  <══════║═════╝   ║ obl:tmod
which     PRON  <════╗ ║         ║ nsubj
had       VERB  ═══╗═╝<╝         ║ acl:relcl
no        DET   <╗ ║             ║ det
name      NOUN  ═╝<╝             ║ obj
.         PUNCT <════════════════╝ punct

Usage with spacy-udpipe

>>> import spacy_udpipe
>>> nlp=spacy_udpipe.load("en")
>>> doc=nlp("I saw a horse yesterday which had no name.")
>>> import deplacy
>>> deplacy.render(doc)
I         PRON  <════════╗   nsubj
saw       VERB  ═══╗═╗═╗═╝═╗ ROOT
a         DET   <╗ ║ ║ ║   ║ det
horse     NOUN  ═╝<╝ ║ ║   ║ obj
yesterday NOUN  <════╝ ║   ║ obl:tmod
which     PRON  <════╗ ║   ║ nsubj
had       VERB  ═══╗═╝<╝   ║ acl:relcl
no        DET   <╗ ║       ║ det
name      NOUN  ═╝<╝       ║ obj
.         PUNCT <══════════╝ punct

Usage with spaCy-jPTDP

>>> import spacy_jptdp
>>> nlp=spacy_jptdp.load("en_ewt")
>>> doc=nlp("I saw a horse yesterday which had no name.")
>>> import deplacy
>>> deplacy.render(doc)
I         PRON  <══════════╗   nsubj
saw       VERB  ═══╗═════╗═╝═╗ ROOT
a         DET   <╗ ║     ║   ║ det
horse     NOUN  ═╝<╝     ║   ║ obj
yesterday NOUN  ═══════╗<╝   ║ obl:tmod
which     PRON  <════╗ ║     ║ nsubj
had       VERB  ═══╗═╝<╝     ║ acl:relcl
no        DET   <╗ ║         ║ det
name      NOUN  ═╝<╝         ║ obj
.         PUNCT <════════════╝ punct