CompletedSubTask' object has no attribute 'aspect_representation - nlp

I am working on an aspect based sentiment.
I am just trying to get the code to work which is in example on the module blog.
but i have this error:
html = absa.probing.explain(slack)
display(html)
AttributeError Traceback (most recent call last)
<ipython-input-20-98b6fe874b12> in <module>
----> 1 html = absa.probing.explain(slack)
2 display(html)
~/Library/Python/3.8/lib/python/site-packages/aspect_based_sentiment_analysis/probing/plots.py in explain(example)
47
48 def explain(example: PredictedExample):
---> 49 aspect = example.aspect_representation
50 texts = [f'Words connected with the "{example.aspect}" aspect: <br>']
51 texts.extend(highlight_sequence(aspect.tokens, aspect.look_at))
AttributeError: 'CompletedSubTask' object has no attribute 'aspect_representation'
Here more : https://pypi.org/project/aspect-based-sentiment-analysis/

Related

AttributeError: module 'ee' has no attribute 'Reducer'

I'm learning GEE recently with accessing VPN but met error as show below:
#######################################################
import ee
import geemap
import os
geemap.set_proxy(port=7890)
os.environ['HTTP_PROXY'] = 'http://127.0.0.1:7890'
os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:7890'
Map = geemap.Map()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In [5], line 7
5 os.environ['HTTP_PROXY'] = 'http://127.0.0.1:7890'
6 os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:7890'
----> 7 Map = geemap.Map()
File ~\anaconda3\envs\gee\lib\site-packages\geemap\geemap.py:173, in
Map.__init__(self, **kwargs)
171 self.roi_end = False
172 if kwargs["ee_initialize"]:
--> 173 self.roi_reducer = ee.Reducer.mean()
174 self.roi_reducer_scale = None
176 # List for storing pixel values and locations based on user-drawn
geometries.
AttributeError: module 'ee' has no attribute 'Reducer'
##############################################################
I checked too many answers through forum but nothing work. Is there anyone who knows the reason? really appreciate it!

How can I use 'torch.utils.mobile_optimizer' in PyTorch 1.6.0?

According to https://pytorch.org/docs/stable/mobile_optimizer.html (currently for 1.6.0)
Torch mobile supports torch.mobile_optimizer.optimize_for_mobile utility to run a list of optimization pass with modules in eval mode. The method takes the following parameters: a torch.jit.ScriptModule object, a blacklisting optimization set and a preserved method list
The page title and
torch.utils.mobile_optimizer.optimize_for_mobile(script_module, optimization_blacklist: Set[torch._C.MobileOptimizerType] = None)
at the end suggest it should be torch.utils.mobile_optimizer instead. However, neither work for me:
In [25]: module1 = torch.utils.mobile_optimizer.optimize_for_mobile(module)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-25-79e42fe53cdf> in <module>
----> 1 module1 = torch.utils.mobile_optimizer.optimize_for_mobile(module)
AttributeError: module 'torch.utils' has no attribute 'mobile_optimizer'
In [26]: module1 = torch.mobile_optimizer.optimize_for_mobile(module)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-26-469dd450df3d> in <module>
----> 1 module1 = torch.mobile_optimizer.optimize_for_mobile(module)
AttributeError: module 'torch' has no attribute 'mobile_optimizer'
In [27]: print(torch.__version__)
1.6.0
Am I missing anything? E.g. do I have to install some package other than torch itself?
import torch.utils.mobile_optimizer as mobile_optimizer
scripted_model = torch.jit.script(model, pt_inputs)
opt_model = mobile_optimizer.optimize_for_mobile(scripted_model)
torch.jit.save(opt_model, "model.pt")
It works for me

module 'hnswlib' has no attribute 'Index'

I downloaded hnswlib package to my env but I am constantly getting an error about
AttributeError Traceback (most recent call last)
in
1 # Declaring index
----> 2 p = hnswlib.Index(space = 'cosine', dim = EMBEDDING_SIZE) # possible options are l2, cosine or ip
AttributeError: module 'hnswlib' has no attribute 'Index'
changing env didn't help

Converting a generator into a list, but getting Error: '_io.TextIOWrapper' object has no attribute 'decode' (python 3.6.4)

I am working with a text in utf-8.
I want to tokenize it and then convert it into a list.
However I get the following error.
import nltk, jieba, re, os
with open('file.txt') as f:
tokenized_text = jieba.cut(f,cut_all=True)
type(tokenized_text)
generator
word_list = list(tokenized_text)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-5-16b25477c71d> in <module>()
----> 1 list(new)
~/anaconda3/lib/python3.6/site-packages/jieba/__init__.py in cut(self, sentence, cut_all, HMM)
280 - HMM: Whether to use the Hidden Markov Model.
281 '''
--> 282 sentence = strdecode(sentence)
283
284 if cut_all:
~/anaconda3/lib/python3.6/site-packages/jieba/_compat.py in strdecode(sentence)
35 if not isinstance(sentence, text_type):
36 try:
---> 37 sentence = sentence.decode('utf-8')
38 except UnicodeDecodeError:
39 sentence = sentence.decode('gbk', 'ignore')
AttributeError: '_io.TextIOWrapper' object has no attribute 'decode'
I understand the problem lies somewhere in the jieba package.
I also tried to change the code into
with open('file.txt') as f:
new = jieba.cut(f,cut_all=False)
but got the same result.
jieba.cut takes a string, not a file. This is explained in the readme.

Jupyter notebook

I am trying to run this code in jupyter notebook but I am getting the following error for fuzzyset package. I am using fuzzyset version 0.0.9. Does anybody know how to convert these dictionary values to list?
agrovocSimple = []
with open('agrovocLabels.json') as data_file:
agrovoc = json.load(data_file)
results = agrovoc["results"]["bindings"]
for entry in results:
uri = entry["uri"]["value"]
label = entry["label"]["value"]
#agrovocSimple.append({"uri": uri , "name": label})
agrovocSimple.append(label)
####instatiation of the fuzzyset for the mappings
# allocate the FuzzySet object
a=FuzzySet()
for e in agrovocSimple:
a.add(e)
####TypeError Traceback (most recent call last)
<ipython-input-19-bc4871be0e65> in <module>()
17 a=FuzzySet()
18 for e in agrovocSimple:
---> 19 a.add(e)
fuzzyset\cfuzzyset.pyx in cfuzzyset.cFuzzySet.add()
fuzzyset\cfuzzyset.pyx in cfuzzyset.cFuzzySet._add()
TypeError: Expected list, got dict_values

Resources