stenskjaer / samewords

Automatically annotate potentially ambiguous words in critical text editions made with LaTeX and reledmac.
MIT License
7 stars 1 forks source link

error when nesting without lemma #8

Closed floriandk closed 7 years ago

floriandk commented 7 years ago
\documentclass[draft]{article}

\usepackage[series={A},nofamiliar,noeledsec,noledgroup]{reledmac}

\begin{document}

\beginnumbering
\pstart
et \edtext{hic \edtext{et}{\Afootnote{÷ A}} hoc}{\Afootnote{ille et illud B}} et cetera
\pend
\endnumbering

\end{document}

aborts with

  File "/usr/local/bin/samewords", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/samewords/cli.py", line 31, in main
    print(samewords.core.process_document(filename))
  File "/usr/local/lib/python3.6/site-packages/samewords/core.py", line 14, in process_document
    updated_paragraphs = [annotate.critical_note_match_replace_samewords(par) for par in paragraphs]
  File "/usr/local/lib/python3.6/site-packages/samewords/core.py", line 14, in <listcomp>
    updated_paragraphs = [annotate.critical_note_match_replace_samewords(par) for par in paragraphs]
  File "/usr/local/lib/python3.6/site-packages/samewords/annotate.py", line 714, in critical_note_match_replace_samewords
    result = sub_processing(TextSegment(text))
  File "/usr/local/lib/python3.6/site-packages/samewords/annotate.py", line 698, in sub_processing
    if search_in_proximity(search_word, context.before, context.after):
  File "/usr/local/lib/python3.6/site-packages/samewords/annotate.py", line 455, in search_in_proximity
    if re.search(r'\b' + search_word + r'\b', maintext_words):
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 182, in search
    return _compile(pattern, flags).search(string)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_compile.py", line 562, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 856, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, False)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 415, in _parse_sub
    itemsappend(_parse(source, state, verbose))
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 501, in _parse
    code = _escape(source, this, state)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 401, in _escape
    raise source.error("bad escape %s" % escape, len(escape))
sre_constants.error: bad escape \e at position 6

As

et \edtext{hic \edtext{et}{\Afootnote{÷ A}} hoc}{\lemma{test}\Afootnote{ille et illud B}} et cetera

works, this has obviously something to do with the first \edtext not having a \lemma even though I am using vers 0.1.3 installed via pip.

floriandk commented 7 years ago

Works here with the issue-9 branch on smaller examples.