AmyOlex / Chrono

Parsing time normalizations from text.
GNU General Public License v3.0
15 stars 4 forks source link

UnboundLocalError: local variable 'chrono_month_entity' referenced before assignment #83

Closed AmyOlex closed 6 years ago

AmyOlex commented 6 years ago

I thought we had fixed this, but it looks like it got fixed in the Year parsing, but not the 2DigitYear parsing! Here is the error message that it spits out when running on the n2c2 data:

Traceback (most recent call last): File "Chrono.py", line 168, in chrono_master_list, my_chrono_ID_counter = BuildEntities.buildChronoList(tempPhrases, my_chrono_ID_counter, chroList, (classifier, args.m), feats, doctime) File "/Users/alolex/Desktop/VCU_PhD_Work/Chrono/Chrono/BuildEntities.py", line 76, in buildChronoList chrono_tmp_list, chrono_id, chrono_time_flags = MonthYear.build2DigitYear(s, chrono_id, chrono_tmp_list, chrono_time_flags) File "/Users/alolex/Desktop/VCU_PhD_Work/Chrono/Chrono/TimePhraseToChrono/MonthYear.py", line 229, in build2DigitYear chrono_month_entity.set_sub_interval(chrono_day_entity.get_id()) UnboundLocalError: local variable 'chrono_month_entity' referenced before assignment

The problem is coming from the line "In the [Hospital1 18] ED, 35.3 102 133/58 100%AC 500x20, 5, 1.0 with an ABG 7.16/66/162." where the last token "7.16/66/162." is being interpreted as a formatted date and Chrono is finding the 16 to be a 2digit year, then returns 100 as the month because it can find no month. I think this just need to be indented so that the day is only searched for if a month is found. This needs to be fixed all the way down and in Year as well.

AmyOlex commented 6 years ago

I fixed this with commit 743f4cd0afb8d8a3b62cf6bf8c9c47f7fb06c163 where I just properly indented all lines of code so that we are no longer trying to reference a variable before we create it.