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

python3 issues in normalization/simstring code #1393

Open william-dowling opened 2 years ago

william-dowling commented 2 years ago

I have installed simstring successfully. Then from a fresh checkout from the master branch, I ran the command python tools/norm_db_init.py example-data/normalisation/Wiki.txt as per the instruction here. This results in

 python tools/norm_db_init.py example-data/normalisation/Wiki.txt
Error building simstring DB
Traceback (most recent call last):
  File "/var/www/fork-brat/brat/tools/norm_db_init.py", line 430, in <module>
    sys.exit(main(sys.argv))
  File "/var/www/fork-brat/brat/tools/norm_db_init.py", line 399, in main
    with Simstring(ssdbfn,
  File "/var/www/fork-brat/brat/tools/../server/src/simstringlib.py", line 35, in __init__
    self.db.measure = SIMILARITY_MEASURES[similarity_measure]
NameError: name 'SIMILARITY_MEASURES' is not defined

If I change SIMILARITY_MEASURES to self.SIMILARITY_MEASURES the program runs successfully.

Now when I select a span in the UI and do New Annotation > Normalization > Quick Add > Search I get no result and see this in /var/log/apache2/error.log:

Traceback (most recent call last):
  File "/var/www/brat/server/src/server.py", line 338, in serve
    return _safe_serve(params, client_ip, client_hostname, cookie_data)
  File "/var/www/brat/server/src/server.py", line 206, in _safe_serve
    json_dic = dispatch(http_args, client_ip, client_hostname)
  File "/var/www/brat/server/src/dispatch.py", line 315, in dispatch
    json_dic = action_function(*action_args)
  File "/var/www/brat/server/src/norm.py", line 446, in norm_search
    return _norm_search_impl(database, name, collection, exactmatch)
  File "/var/www/brat/server/src/norm.py", line 377, in _norm_search_impl
    best_score = _norm_search_name_attr(ss, name, None,
  File "/var/www/brat/server/src/norm.py", line 304, in _norm_search_name_attr
    str_scores = ss.supstring_lookup(normname, True)
  File "/var/www/brat/server/src/simstringbase.py", line 87, in supstring_lookup
    result = self.lookup(s)
  File "/var/www/brat/server/src/simstringlib.py", line 47, in lookup
    assert not self.build, "Error: lookup on build simstring"
AssertionError: Error: lookup on build simstring

I guess this is caused by using self.build in the assert statement, which should have been self.is_build.