def test_hitfilter_list_suggestion_results_with_deprecated_subjects( subject_index): subject_index.append('http://example.org/deprecated', None, None) suggestions = ListSuggestionResult([ SubjectSuggestion(uri='http://www.yso.fi/onto/yso/p7141', label='sinetit', notation=None, score=1.0), SubjectSuggestion(uri='http://www.yso.fi/onto/yso/p6479', label='viikingit', notation=None, score=0.5), SubjectSuggestion(uri='http://example.org/deprecated', label=None, notation=None, score=0.5) ]) filtered_suggestions = SuggestionFilter(subject_index)(suggestions) assert isinstance(filtered_suggestions, SuggestionResult) assert len(filtered_suggestions) == 2 assert filtered_suggestions.as_list( subject_index)[0] == suggestions.as_list(subject_index)[0] assert filtered_suggestions.as_list( subject_index)[1] == suggestions.as_list(subject_index)[1]
def test_hitfilter_vector_suggestion_results_with_deprecated_subjects( subject_index): subject_index.append('http://example.org/deprecated', None, None) vector = np.ones(len(subject_index)) suggestions = VectorSuggestionResult(vector) filtered_suggestions = SuggestionFilter(subject_index)(suggestions) assert len(suggestions) == len(filtered_suggestions) \ + len(subject_index.deprecated_ids()) deprecated = SubjectSuggestion(uri='http://example.org/deprecated', label=None, notation=None, score=1.0) assert deprecated in suggestions.as_list(subject_index) assert deprecated not in filtered_suggestions.as_list(subject_index)