how to make short/simple URLs?

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

how to make short/simple URLs?

mario7111
Hi,

How do I keep the links as clean as possible? I mean instead of having "http://www.semanticweb.org/marius/ontologies/2021/6/app#Advisory", I would like to use only mywebsite.com/Advisory.

I made a change to xml:base="app/" but it still add some other characters. For example now the link is this: http://127.0.0.1:5000/app/%23Advisory. I would like to be just /Advisory, without %23.

Thank you,

Marius
Reply | Threaded
Open this post in threaded view
|

Re: how to make short/simple URLs?

Jiba
Administrator
Hi,

The IRI must be an URL, so it cannot start by "app/". You can use "http://mywebsite.com/" as xml:base if you want, but you cannot remove the HTTP protocol name or the server name.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: how to make short/simple URLs?

mario7111
Hi,

Thank you for your answer. I am aware of this however maybe I was not very clear in my message.

Let's suppose I will use http://mywebsite.com as xml:base but the link will be http://mywebsite.com/%23Advisory

'Advisory' is just a class name, however the link contains %23 before the class name 'Advisory'.

Is there a way to keep the link clean? Without "%23"? Like this: http://mywebsite.com/Advisory

Thank you,

Marius





Reply | Threaded
Open this post in threaded view
|

Re: how to make short/simple URLs?

Jiba
Administrator
Hi,

I'm not sure from where comes the "%23". The IRI can normally be "http://mywebsite.com/Advisory" or "http://mywebsite.com/onto.owl#Advisory".

In Owlready, you should create the ontology as follows:

onto = get_ontology ("http://mywebsite.com/") # for http://mywebsite.com/Advisory ; notice that the last / is mandatory

or:

onto = get_ontology ("http://mywebsite.com/onto.owl") # for http://mywebsite.com/onto.owl#Advisory


If you are modifying "xml:base" in the ontology OWL file, please notice that you possibly also have to modify "xmlns" and "rdf:about" of the Ontology object -- there is some redundancy here!

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: how to make short/simple URLs?

mario7111
Hi,

Actually I am importing an .owl file that I created in Protege:

onto = get_ontology("app.owl").load()

Can be an issue with the file? Should I create the ontology in Owlready (without using Protege)?

Thank you,

Marius
Reply | Threaded
Open this post in threaded view
|

Re: how to make short/simple URLs?

mario7111
In reply to this post by Jiba
Hi Jiba,

I found the 'issue'. Every new added class or instance in Protege, it adds # symbol before name. For example, if I look for the class Advisory in the .owl file, I see it as #Advisory with '#' character.

According to ASCII Encoding Reference, the symbol '#' is %23, exactly what appears in my links.

I could simply go to the .owl file and delete the '#' symbol before any named class or instance but this is the  best way to do it? Or there is another and better way to do it?

Thank you,

Marius
Reply | Threaded
Open this post in threaded view
|

Re: how to make short/simple URLs?

mario7111
In reply to this post by Jiba
Hi again,

I loaded the bacteria.owl from your github repository, I can see in the links the %23 which is the '#' symbol according to ASCII Encoding Reference.

Here is the link:

http://localhost:5000/class/http://lesfleursdunormal.fr/static/_downloads/bacteria.owl%23Coccus

Also, I attached a picture too so you can see the %23 before Coccus

Reply | Threaded
Open this post in threaded view
|

Re: how to make short/simple URLs?

Jiba
Administrator
Hi,

%23 is used to replace # in URL, because # is normally used for something else in URL (for fragments). I think the presence of %23 is not a problem.

If you really want to avoid %23 in URL, e.g. for cosmetic reasons, you may replace it manually with something else (e.g. "SHARP"), or remove it from the URL and add it after, just before obtaining the entity from the IRI (but this would work only if all your entities starts with #).

Jiba