diff --git a/spacy/displacy/render.py b/spacy/displacy/render.py index 40b9986e85b..72425b9c3f7 100644 --- a/spacy/displacy/render.py +++ b/spacy/displacy/render.py @@ -442,15 +442,17 @@ def render_arrow( y_curve = -self.distance arrowhead = self.get_arrowhead(direction, x_start, y, x_end) arc = self.get_arc(x_start, y, y_curve, x_end) - label_side = "right" if self.direction == "rtl" else "left" + label_arc = arc + if self.direction == "rtl": + label_arc = self.get_arc(x_end, y, y_curve, x_start) return TPL_DEP_ARCS.format( id=self.id, i=i, stroke=self.arrow_stroke, head=arrowhead, label=label, - label_side=label_side, arc=arc, + label_arc=label_arc, ) def get_arc(self, x_start: int, y: int, y_curve: int, x_end: int) -> str: diff --git a/spacy/displacy/templates.py b/spacy/displacy/templates.py index 40f5376b18d..b9376b379cd 100644 --- a/spacy/displacy/templates.py +++ b/spacy/displacy/templates.py @@ -26,8 +26,9 @@ TPL_DEP_ARCS = """ + - {label} + {label} diff --git a/spacy/tests/test_displacy.py b/spacy/tests/test_displacy.py index b83c7db07f4..76086081cd7 100644 --- a/spacy/tests/test_displacy.py +++ b/spacy/tests/test_displacy.py @@ -329,6 +329,9 @@ def test_displacy_rtl(): assert "direction: rtl" in html assert 'direction="rtl"' in html assert f'lang="{nlp.lang}"' in html + assert 'class="displacy-label-arc"' in html + assert 'xlink:href="#label-' in html + assert " side=" not in html html = displacy.render(doc, page=True, style="ent") assert "direction: rtl" in html assert f'lang="{nlp.lang}"' in html