使用 Latex 进行 NLP 的 Brat

使用 Latex 进行 NLP 的 Brat

我想知道是否有任何用于 Latex 文本注释的包,例如小子

这是我希望在图中得到的结果:

在此处输入图片描述

有没有办法通过使用 brat 或其他一些库来实现这一点,而无需使用 inkscape 绘制并将其转换为 svg,或者使用 tikz?

接受所有解决方案和提示!

答案1

只是为了好玩,因为我不知道tikz-dependency他在评论中引用的 percusse 包。

\documentclass{article}
\usepackage{tikz-dependency}
\usetikzlibrary{decorations.pathreplacing}

\begin{document}
\begin{dependency}[label style={draw=white}]
\begin{deptext}[column sep=1em,
row 2/.style={nodes={fill=cyan!16, draw=white}}]
PRP \& VBD \& NNP \& NNP \&[2.5em] POS \& NN \&[-.5em] .\\[1.6ex]
It \& was \& Jesse \& Bear \& 's \& birthday \& . \\
\end{deptext}
\depedge[edge unit distance=2.5ex]{6}{1}{nsubj}
\depedge[edge unit distance=2.3ex]{6}{2}{cop}
\depedge{6}{4}{poss}
\depedge{4}{3}{nn}
\depedge{4}{5}{possesive}
\wordgroup[group style={fill=cyan!40, draw=cyan, inner sep=0pt}]{1}{1}{1}{a}
\wordgroup[group style={fill=green!40, draw=green, inner sep=0pt}]{1}{2}{2}{b}
\wordgroup[group style={fill=blue!40, draw=blue, inner sep=0pt}]{1}{3}{3}{c}
\wordgroup[group style={fill=blue!40, draw=blue, inner sep=0pt}]{1}{4}{4}{d}
\wordgroup[group style={fill=violet!40, draw=violet, inner sep=0pt}]{1}{5}{5}{e}
\wordgroup[group style={fill=blue!40, draw=blue, inner sep=0pt}]{1}{6}{6}{f}
\wordgroup[group style={fill=red!40, draw=red, inner sep=0pt}]{1}{7}{7}{g}
\foreach \ind in {1,..., 7}{
\draw[blue,decorate,decoration={brace}] (\wordref{2}{\ind}.north west)-- (\wordref{2}{\ind}.north east);}
\end{dependency}
\end{document}

在此处输入图片描述

相关内容