'NoneType' object has no attribute 'start_char'
mldulaney opened this issue · 6 comments
In [1]: from mordecai.geoparse import Geoparser
Using TensorFlow backend.
In [2]: geoparser = Geoparser(es_ip='elasticsearch', es_port=9000)
WARNING:tensorflow:From /usr/local/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
WARNING:tensorflow:From /usr/local/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.
Instructions for updating:
Please use rate
instead of keep_prob
. Rate should be set to rate = 1 - keep_prob
.
2019-05-01 17:35:36.040922: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-05-01 17:35:36.056207: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2592000000 Hz
2019-05-01 17:35:36.056768: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x55e9cc3f97b0 executing computations on platform Host. Devices:
2019-05-01 17:35:36.056795: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): ,
WARNING:tensorflow:From /usr/local/lib/python3.7/site-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
You may be using an outdated Geonames index. Your index is from 2019-04-29, while the most recent is 2018-06-05. Please see https://github.com/openeventdata/mordecai/ for instructions on updating.
In [3]: res = geoparser.geoparse("The ship entered Greenville from Tarboro", verbose=True)
Greenville
'NoneType' object has no attribute 'start_char'
Tarboro
'NoneType' object has no attribute 'start_char'
In [4]: res
Out[4]: []
Same issue here.
(FYI, I am not affiliated with this project at all)
So I spent some time tracing this down, and I'm not sure if this is the correct fix but I found that when installing this from pip, then the code is slightly different.
Starting at line 513:
` try:
start = ent.start_char - ent.sent.start_char
end = ent.end_char - ent.sent.start_char
iso_label = maj_vote
try:
text_label = self._inv_cts[iso_label]
except KeyError:
text_label = ""
task = {"text" : ent.sent.text,`
It is getting hung up on the ent.sent. if you remove the -ent.sent.start_char from both start and end variables and then change "text": ent.sent.text" to "text":ent.text" then it should work. I only tested it out with the example on the front page and it returned the correct results. Not sure why that is in there or why the pip install is different from the git code.
Hope this helps.
Sorry for the discrepancy between the Github and PyPI versions. I've upgraded the PyPI version to match Github, and it's passing all my tests. If you experience the same issue with the latest version (2.0.3), please let me know!
Hey, thanks! I'll give it a test here in a bit.
Tested with 2.0.3 package. It works without spitting out those exceptions. Thank you!
PS: I see that releases on github are still at 2.0.1 btw.
Fixed