Has problems with load local owl ontology which has importing other two local ontologies.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Has problems with load local owl ontology which has importing other two local ontologies.

ShirleyWx
Hello,
I have two problems with loading ontologies and importing ontologies.

1、The first problem
    When importing ontology, how can I only import the instance of the ontology ,  (the ontology and the importing ontology have the same Classes )

2、The second problem
          path = 'file://yang_v2-union.owl'
          unionOnto = get_ontology(path).load()  

 When I use the codes as above to load the ontology which has importing other two ontologies (that is the owl file has the following statements: 'owl:imports rdf:resource=....'),I will meet the following errors(fstarting from 'Traceback'. I can not solve the problem. Please help me! Thank you!

Traceback (most recent call last):
  File "D:\Anaconda3\lib\urllib\request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "D:\Anaconda3\lib\http\client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "D:\Anaconda3\lib\http\client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "D:\Anaconda3\lib\http\client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "D:\Anaconda3\lib\http\client.py", line 1026, in _send_output
    self.send(msg)
  File "D:\Anaconda3\lib\http\client.py", line 964, in send
    self.connect()
  File "D:\Anaconda3\lib\http\client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "D:\Anaconda3\lib\socket.py", line 704, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "D:\Anaconda3\lib\socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Anaconda3\lib\site-packages\owlready2\namespace.py", line 721, in load
    try:     fileobj = urllib.request.urlopen(f)
  File "D:\Anaconda3\lib\urllib\request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "D:\Anaconda3\lib\urllib\request.py", line 526, in open
    response = self._open(req, data)
  File "D:\Anaconda3\lib\urllib\request.py", line 544, in _open
    '_open', req)
  File "D:\Anaconda3\lib\urllib\request.py", line 504, in _call_chain
    result = func(*args)
  File "D:\Anaconda3\lib\urllib\request.py", line 1346, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "D:\Anaconda3\lib\urllib\request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 11001] getaddrinfo failed>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "F:/Code/YANG_Parse/UnionKG.py", line 5, in <module>
    unionOnto = get_ontology(path).load()
  File "D:\Anaconda3\lib\site-packages\owlready2\namespace.py", line 762, in load
    imported_ontologies = [self.world.get_ontology(self._unabbreviate(abbrev_iri)).load() for abbrev_iri in self.world._get_obj_triples_sp_o(self.storid, owl_imports)]
  File "D:\Anaconda3\lib\site-packages\owlready2\namespace.py", line 762, in <listcomp>
    imported_ontologies = [self.world.get_ontology(self._unabbreviate(abbrev_iri)).load() for abbrev_iri in self.world._get_obj_triples_sp_o(self.storid, owl_imports)]
  File "D:\Anaconda3\lib\site-packages\owlready2\namespace.py", line 722, in load
    except:  raise OwlReadyOntologyParsingError("Cannot download '%s'!" % f)
owlready2.base.OwlReadyOntologyParsingError: Cannot download 'http://www.wx.com/ontologies/yangRFC/yang_v2_ietfInterface.owl'!


How can I solve the baove two problems?
Many thanks.
Shirley
     
Reply | Threaded
Open this post in threaded view
|

Re: Has problems with load local owl ontology which has importing other two local ontologies.

Jiba
Administrator
Hello,

For the first problem, do you mean that you want to load only the ontology, but not the other ontologies it imports?

For the second problem, the problem is that the imported ontology is not available online (the URL does not respond). In this case, if you want to work with local copies, you should put all OWL file in a given directory, and add this directory to the list onto_path, for example:

onto_path.append("/path/to/directory/with/owl/files")

Jiba