Unable to create owl:NamedIndividual on owlready2 - python

I need to create a NamedIndividual (https://www.w3.org/TR/owl2-syntax/#Named_Individuals) but I am not seeing a way to do it.
The following example:
from owlready2 import *
onto = get_ontology("example")
class NamedIndividual(Thing): namespace = owl
print(NamedIndividual.iri)
print(NamedIndividual.name)
mini = NamedIndividual()
onto.save("minrep.rdf")
Gives the following error:
http://www.w3.org/2002/07/owl#NamedIndividual
NamedIndividual
Traceback (most recent call last):
File "minrep.py", line 13, in <module>
mini = NamedIndividual("example")
File "/home/lubianat/Documents/main_venv/lib/python3.8/site-packages/owlready2/individual.py", line 137, in __init__
if self.storid > 0: self.namespace.ontology._add_obj_triple_spo(self.storid, rdf_type, owl_named_individual)
TypeError: '>' not supported between instances of 'str' and 'int'
If I instantiate the class without a name, I get another error:
http://www.w3.org/2002/07/owl#NamedIndividual
NamedIndividual
Traceback (most recent call last):
File "minrep.py", line 13, in <module>
mini = NamedIndividual()
File "/home/lubianat/Documents/main_venv/lib/python3.8/site-packages/owlready2/individual.py", line 123, in __init__
iri = self.namespace.world._new_numbered_iri("%s%s" % (self.namespace._base_iri, self.generate_default_name()))
AttributeError: 'World' object has no attribute '_new_numbered_iri'
Any ideas on what is happening there? Thanks!

Related

Why there is STAFRegister error in PySTAF.py?

I am getting the below error. I have used capital letters PYSTAF too, still getting the same error.
Traceback (most recent call last):
File "C:\Python27\STAFtest.py", line 16, in <module>
handle = STAFHandle("Lang/Python/Test/Basic")
File "D:\STAF\bin\PySTAF.py", line 137, in __init__
rc, self.handle = PySTAF.STAFRegister(handleNameOrNumber)
AttributeError: 'module' object has no attribute 'STAFRegister'

Python built-in help function throws an error

When I try to get help information on any of the built-in functions, it returns the following error:
Version: 3.7.4
>>> help(len)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\hgak\AppData\Local\Programs\Python\Python38-32\lib\_sitebuiltins.py", line 103, in __call__
return pydoc.help(*args, **kwds)
varchars = string.ascii_letters + string.digits + '_-'
AttributeError: module 'string' has no attribute 'ascii_letters'

why web3.eth.getBlock gives null answer and getTransactionReceipt gives error?

I am using Web3.py in my python code. The code is like this
from web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://ropsten.infura.io/"))*
for i in range(5000000,5100000):
print(i)
transactionArray = []
blockResult = w3.eth.getBlock(i)
for tx in blockResult["transactions"]:
txResult = binascii.hexlify(tx).decode()
print(txResult)
transactionResult = w3.getTransactionReceipt(txResult)
print(transactionResult)
When I execute this code, getting error
5000000
Traceback (most recent call last):
File "Test06.py", line 27, in <module>
for tx in blockResult["transactions"]:
TypeError: 'NoneType' object is not subscriptable
but If I start range from 4571699 it gives me the result. Can somebody tell me why I'm getting an error for range starts from 5000000
I use the MAIN NET, so resolved this problem. But now I am getting an error as
Traceback (most recent call last):
File "Test06.py", line 35, in <module>
transactionResult = w3.getTransactionReceipt(txResult)
AttributeError: 'Web3' object has no attribute 'getTransactionReceipt'.
You're using the ropsten test chain which only has 4572019 blocks as of this answer.

'generator' object has no attribute error in accessing the tree levels in python

This is my code:
from nltk import load_parser
cp = load_parser('grammars/book_grammars/sql0.fcfg')
query = 'What cities are located in China'
trees = cp.parse(query.split())
answer = trees[0].node['sem']
Here is the error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'generator' object has no attribute '__getitem__'
Why it is giving such error, what is the solution of it?

why do I get the following error in get request

I have code like this :
import requests
import xmltodict
Locations = ['http://129.94.5.93:49154/setup.xml', 'http://129.94.5.92:49154/setup.xml', 'http://129.94.5.93:49154/setup.xml', 'http://129.94.5.92:49154/setup.xml', 'http://129.94.5.95:80/description.xml']
for item in Locations:
r = requests.get(item)
reply = xmltodict.parse(r.text)
this gives me the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ssdpxml.py", line 57, in <module>
r = requests.get(item)
AttributeError: 'str' object has no attribute 'get'
But it works when I do this:
r=requests.get('http://129.94.5.95:80/description.xml')
Why do I get the above mentioned error??

Categories

Resources