Gráfico de árbol de dependencia con flechas adicionales

Gráfico de árbol de dependencia con flechas adicionales

Construí el árbol (componentes negros) usando el Stanford Parser. Sin embargo, no hace que sus gráficos sean exportables, así que tuve que tomar una captura de pantalla. Luego a ese gráfico tuve que agregar las dos nuevas filas coloridas con esa etiqueta.

Obviamente al importar esto como JPG en látex, obtengo muy malos resultados al imprimir. ¿Alguien puede ayudar o dar sugerencias sobre cómo reproducir este gráfico o parte de él y qué debo usar para lograrlo?

ingrese la descripción de la imagen aquí

Respuesta1

Aquí hay una forma de hacer el árbol en LaTeX usando el forestpaquete:

\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}

árbol

Respuesta2

Dado que cfr proporcionó una buena solución con el forestpaquete, aquí hay una con Tikz.

Producción

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}

información relacionada