Enhancement/Auto-generate label shortkeys and colors on corpus import #199
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #5 (comment), @jamesmf brought up the suggestion to auto-generate shortkeys and colors for each imported label. This idea provides a great improvement to the user experience since the user can upload a partially annotated corpus and quickly start annotating efficiently afterwards thanks to all the shortkeys and colors already being assigned.
This pull request implements the automatic generation of label shortkeys and colors when a corpus is imported.
For each new label, we attempt to use the first character of the label text as the shortkey. If this is already set, we add modifier keys like ctrl, shift and ctrl+shift until we find a shortkey that doesn't yet exist. If all the shortkeys already exist, we move onto the next character in the label text and try again.
For each new label, we also auto-generate a background color and a foreground color as per the same algorithm that the frontend uses.