Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort the prefixes by popularity #17

Open
VladimirAlexiev opened this issue Aug 27, 2015 · 7 comments
Open

sort the prefixes by popularity #17

VladimirAlexiev opened this issue Aug 27, 2015 · 7 comments

Comments

@VladimirAlexiev
Copy link

Run this several times

perl -MRDF::NS -e "print RDF::NS->new(1)->PREFIX('http://www.w3.org/2001/XMLSchema#')"

and you get different answers, eg xs xds etc.

The doc says "If multiple prefixes are defined, it is not determinstic which one is returned!" But I wonder why it has to be so:

If you ask http://prefix.cc about http://www.w3.org/2001/XMLSchema# it confidently answers xsd. It has these voting buttons so worse alternatives like xs xds are not returned. Can't the module use this voting info?

@VladimirAlexiev
Copy link
Author

http://prefix.cc/popular/all.txt seems to return them in the right order:

@kjetilk
Copy link
Contributor

kjetilk commented Jan 11, 2017

I suppose it comes down to an implementation detail, that the mapping is represented internally as a hash, and therefore unordered. So, it is probably just a matter of having time to change it so that there is a an array of prefixes... I tend to agree, this behaviour is rather odd, but someone has to set aside time to do it. :-)

@nichtich
Copy link
Owner

The current release returns them in sorted order - I don't mind changing the order to something else. This only affects reverse lookup which is less relevant because every RDF serialization should declare its prefix-namespace mapping anyway.

@VladimirAlexiev
Copy link
Author

Version 20150725 returned xmls.
Version 20170111 returns xds. I guess by "sorted order" you mean "alphabetically sorted": but that's not good, it should be "sorted by popularity" (i.e. as in http://prefix.cc/popular/all.txt)

every RDF serialization should declare its prefix-namespace mapping

If your module does reverse lookup in prefix.cc, please do it right. Else remove this function.

@kjetilk
Copy link
Contributor

kjetilk commented Jan 12, 2017

Yeah, I agree that sorted by popularity would be a better solution, but I suppose that's a different issue?

@VladimirAlexiev VladimirAlexiev changed the title why does it pick prefixes undeterministically? sort the prefixes by popularity Jan 13, 2017
@VladimirAlexiev
Copy link
Author

The problem is that the reverse lookup returns BAD prefixes (eg xds) for known namespaces (eg xsd).
Now the issue title corresponds to what we're discussing. Please reopen it.

@nichtich nichtich reopened this Jan 15, 2017
@nichtich
Copy link
Owner

This feature requires an extension of the internal database and the update mechanism for reverse lookup. Each prefix could get an additional popularity ranking (1,2...n) among all prefixes that share the same namespace (additional column in prefix.cc). Updates will not only cover changes of prefix-namespace-mappings but also changes in popularity. The main work is in updating the UPDATE method but this is not on the top of my TODO list, so pull requests are welcome.

By the way RDF::SN uses a different sort order to prefer shorter prefixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants