-
Notifications
You must be signed in to change notification settings - Fork 41
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
Issue274 retain subject ids when loading vocabulary over existing one #383
Issue274 retain subject ids when loading vocabulary over existing one #383
Conversation
Codecov Report
@@ Coverage Diff @@
## master #383 +/- ##
==========================================
+ Coverage 99.38% 99.40% +0.01%
==========================================
Files 59 60 +1
Lines 3738 4026 +288
==========================================
+ Hits 3715 4002 +287
- Misses 23 24 +1
Continue to review full report at Codecov.
|
Demo run:
In
Also, the label The suggestion results with original vocabulary:
After loading updated vocabulary, the suggestion resuls are:
|
uri, _, label = line.strip().partition('\t') | ||
clean_uri = annif.util.cleanup_uri(uri) | ||
yield Subject(uri=clean_uri, label=label, text=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is different in #385.
def append(self, uri, label): | ||
subject_id = len(self._uris) | ||
self._uris.append(uri) | ||
self._labels.append(label) | ||
self._uri_idx[uri] = subject_id | ||
self._label_idx[label] = subject_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method duplicates much of the code in __init__(...)
, so if this is kept, maybe there should be a helper method _append(self, uri, label)
that is used in both? (Also, #385 adds notation
along uri
and label
here.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a reasonable refactoring to extract the common code into a method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good, I only have a few stylistic remarks.
Kudos, SonarCloud Quality Gate passed!
|
def append(self, uri, label): | ||
subject_id = len(self._uris) | ||
self._uris.append(uri) | ||
self._labels.append(label) | ||
self._uri_idx[uri] = subject_id | ||
self._label_idx[label] = subject_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a reasonable refactoring to extract the common code into a method.
Closes #274.