Jupyter notebook - python-3.x

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

Related

KeyError using format with python

I'm new in python and i'm getting this error while trying to run my code
KeyError Traceback (most recent call last)
<ipython-input-201-74e7a7ea82f3> in <module>
----> 1 SEARCH['profession']['call'].format('Jhon',23)
KeyError: '"sea'
This is my code, I am trying to use the format in a string that simulates a dictionary
SEARCH = {
'profession' : {"call":'{"sea:searchProfession":{"datasheet": {"name":{},"age": {}}}}'},
'id' : {"call":'{"sea:searchId":{"personId": {"id":{},"name": {},"age":"{}"}}}'},
}
SEARCH['profession']['call'].format('Jhon',23)
I know there are similar issues, but I have not found the solution

CompletedSubTask' object has no attribute 'aspect_representation

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/

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

global variables inside function python 3.x

guys i am new in python and for some reason the word global not working for me
ex
def location():
global place
place = "Cape Town"
return
and when i am trying to print place
print(place)
i am facing that error
NameError Traceback (most recent call last)
<ipython-input-2-34a3a4594339> in <module>()
----> 1 print(place)
NameError: name 'place' is not defined

Appending a column to large csv file

I have uploaded a large csv into python using the following code:
ddgqa = pd.read_table("/Users/xxxx/Documents/globalqa-pageurls-Report.csv", chunksize= 10**6, iterator=True)
I am now extract a column into a dataframe using this code:
for chunk in ddgqa:
links_adobe_ddgqa = pd.DataFrame(ddga['Page URL'])
When I try to links_adobe_ddgqa
I get the following error:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-95-1ab6eaf23d5f> in <module>()
----> 1 links_adobe_ddgqa
NameError: name 'links_adobe_ddgqa' is not defined
What am I missing? Is there a better way to accomplish this?

Resources