Gráfico de árvore de dependência com setas extras

Gráfico de árvore de dependência com setas extras

Construí a árvore (componentes pretos) usando o Stanford Parser. No entanto, seus gráficos não são exportáveis, então tive que fazer uma captura de tela. Então, nesse gráfico, tive que adicionar as duas novas linhas coloridas com esse rótulo.

Obviamente, ao importar isso como JPG em látex, obtenho resultados muito ruins na impressão. Alguém pode ajudar ou dar dicas de como reproduzir este gráfico ou parte dele e o que devo usar para conseguir isso?

insira a descrição da imagem aqui

Responder1

Aqui está uma maneira de fazer a árvore no próprio LaTeX usando o forestpacote:

\documentclass[tikz,border=5pt]{standalone}
\usepackage{forest}
\usetikzlibrary{arrows.meta}
\begin{document}
  \begin{forest}
    for tree={
      parent anchor=south,
      child anchor=north,
      tier/.wrap pgfmath arg={tier#1}{level()},
      font=\sffamily
    }
    [ROOT, name=root
      [SBARQ
        [WHNP
          [WDT
            [Which]
          ]
          [NP
            [NN
              [animal]
            ]
          ]
        ]
        [SQ
          [VBD
            [was]
          ]
          [RB
            [not, name=not]
          ]
          [VP
            [VBN
              [eaten, name=eaten]
            ]
          ]
        ]
        [.
          [?]
        ]
      ]
    ]
    \draw [ultra thick, blue, -{Triangle[]}] (root.south east) [bend left=65] to node [pos=.25, right, fill=blue, font=\sffamily\footnotesize, text=white, inner sep=1pt, xshift=5pt]  {ROOT}  (eaten.north east) ;
    \draw [ultra thick, red, -{Triangle[]}] (eaten.west) [bend left] to node [pos=.25, left, fill=red, font=\sffamily\footnotesize, text=white, inner sep=1pt, xshift=-5pt]  {NEG}  (not) ;
  \end{forest}
\end{document}

árvore

Responder2

Como o cfr forneceu uma boa solução com o forestpacote, aqui está uma com o Tikz.

Saída

figura 1

Código

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{trees,calc,arrows.meta,positioning,bending}

\tikzset{
    edge from parent/.style={draw, gray},
    coln/.style={scale=0.6,inner sep=2pt, outer sep=0mm,draw=none,fill=#1, text=white},
    >=latex,
}

\begin{document}

\begin{tikzpicture}[
    level/.style={level distance=8mm},
    level 1/.style={sibling distance=25mm},
    level 3/.style={sibling distance=10mm},
    font=\sffamily
    ]

\node (root) {ROOT}
    child {node {SBARQ}
        child {node {WHNP}
            child {node {WDT}
                child {node {Which}
                }
            }
            child {node {NP}
                child {node {NN}
                    child {node {animal}
                    }
                }
            }
        }
        child {node {SQ}
            child {node {VBD}
                child {node {was}
                }}
            child {node {RB}
                child {node (not) {not}
                }}
            child {node {VP}
                child {node {VBN}
                    child {node (eat) {eaten}
                }}
            }
        }
        child[sibling distance=18mm] {node {.}
            child {node {?}
        }
    }
};

\draw[thick, blue!60!black] (root.east)
    edge[out=-10,in=45,->,looseness=1.4] node [midway,right,xshift=.3em,coln=blue!55] {Root}
        ($(eat.north east)+(-1mm,-1mm)$);
\draw[thick, red] (eat.west)
    edge[out=180,in=270,->] node [midway,left,xshift=-.3em,coln=red!60] {NEG}
        (not.south);

\end{tikzpicture}
\end{document}

informação relacionada