nlplab / brat

brat rapid annotation tool (brat) - for all your textual annotation needs
http://brat.nlplab.org
Other
1.82k stars 509 forks source link

"ImportError: No module named ssplit" when running tools/anntoconll.py #1286

Open Dawny33 opened 6 years ago

Dawny33 commented 6 years ago

I am getting the following ImportError when trying to run the file tools/anntoconll.py

Traceback (most recent call last):
  File "tools/anntoconll.py", line 14, in <module>
    from sentencesplit import sentencebreaks_to_newlines
  File "/home/ubuntu/brat/tools/sentencesplit.py", line 12, in <module>
    from ssplit import regex_sentence_boundary_gen
ImportError: No module named 'ssplit'

I am unable to find the file here or in server/src/ too

Dawny33 commented 5 years ago
import os
import re
import sys
from collections import namedtuple
from io import StringIO
from os import path

from sentencesplit import sentencebreaks_to_newlines

# assume script in brat tools/ directory, extend path to find sentencesplit.py
sys.path.append(os.path.join(os.path.dirname(__file__), '../server/src'))

This was because the sys.path was appended after the import, which leads to the problem where Python unable to find the module (in the anntoconll.py file)

Moving the line which appends sys.path to the top helped set the path.