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

Make prefLabel policies deterministic by using label string sort order to break ties #91

Merged
merged 1 commit into from
Aug 31, 2021

Conversation

osma
Copy link
Member

@osma osma commented Aug 31, 2021

In issue #81, @kouralex pointed out that prefLabel selection policies are not deterministic in cases where there are ties - for example if two candidate labels have the same length when using the shortest policy. The proposed solution, implemented in #82, was to introduce locale-aware alphanumeric sorting as a separate policy. But there are problems in the approach of that PR because locale-aware sorting is a bit difficult to implement well.

This PR has narrower scope and only tries to fix the issue of nondeterministic selection. The simple fix is just to use the label itself (its string value) as the final key for sorting, when other policies such as shortest or longest cannot produce a single unambiguous result. The "winning" label may not be any better than the other candidates, but at least it's the same every time.

@osma osma self-assigned this Aug 31, 2021
@osma osma added the bug label Aug 31, 2021
@osma osma merged commit 202ad1e into master Aug 31, 2021
@osma osma deleted the issue81-preflabel-uniqueness-deterministic branch August 31, 2021 10:42
@osma osma added this to the 2.3.0 milestone Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant