Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'ParentedTree' object has no attribute 'unicode_repr' #63

Closed
nurub-tech opened this issue Mar 21, 2021 · 3 comments
Closed

Comments

@nurub-tech
Copy link

Describe the bug
Installed the library using the readme file. Running the example parse_single_from_code.py and got the error

To Reproduce
Tried to copy the cache folder from the library to my local machine under Giveme5W1H like what's explained in #30 didn't solve the issue

Log
Full log of running the example:
No extractors passed: initializing default configuration.
No combinedScorers passed: initializing default configuration.
extractor = <Giveme5W1H.extractor.extractor.MasterExtractor object at 0x000002AFDF407788>
doc = <Giveme5W1H.extractor.document.Document object at 0x000002AFF2344F08>
Exception in thread Thread-4:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\nurub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\Giveme5W1H\extractor\extractor.py", line 20, in run
extractor.process(document)
File "C:\Users\nurub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\Giveme5W1H\extractor\extractors\abs_extractor.py", line 40, in process
self._extract_candidates(document)
File "C:\Users\nurub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\Giveme5W1H\extractor\extractors\cause_extractor.py", line 92, in _extract_candidates
for candidate in self._evaluate_tree(tree):
File "C:\Users\nurub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\Giveme5W1H\extractor\extractors\cause_extractor.py", line 131, in _evaluate_tree
if sibling.label() == 'VP' and "('NP'" in sibling.unicode_repr():
AttributeError: 'ParentedTree' object has no attribute 'unicode_repr'

C:\Users\nurub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\Giveme5W1H\examples\caches\Nominatim.prickle CACHED: Canada: Canada
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\nurub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\Giveme5W1H\extractor\extractor.py", line 20, in run
extractor.process(document)
File "C:\Users\nurub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\Giveme5W1H\extractor\extractors\abs_extractor.py", line 40, in process
self._extract_candidates(document)
File "C:\Users\nurub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\Giveme5W1H\extractor\extractors\environment_extractor.py", line 147, in _extract_candidates
self._cache_nominatim.cache(location_string, location)
File "C:\Users\nurub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\Giveme5W1H\extractor\tools\key_value_cache.py", line 58, in cache
self.persist()
File "C:\Users\nurub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\Giveme5W1H\extractor\tools\key_value_cache.py", line 43, in persist
with open(self._cache_path, 'wb') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\nurub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\Giveme5W1H\examples\caches\Nominatim.prickle'

Versions (please complete the following information):

  • OS: Win10
  • Python 3.7
  • Giveme5W1H Version not sure
  • Stanford CoreNLP Version 3.8
@jinzhao3611
Copy link

I solved this issue by going to the cause_extractor.py and change line 131 from
_if sibling.label() == 'VP' and "('NP'" in sibling.unicode_repr():_
to
if sibling.label() == 'VP' and "('NP'" in sibling.__repr__():

@pmckim1
Copy link

pmckim1 commented Apr 18, 2021

I solved this issue by going to the cause_extractor.py and change line 131 from
_if sibling.label() == 'VP' and "('NP'" in sibling.unicode_repr():_
to
if sibling.label() == 'VP' and "('NP'" in sibling.__repr__():

I had the same problem and this fix worked for me. Thanks for posting!

@fhamborg
Copy link
Owner

fixed with latest pypi version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants