Skip to content

Commit fb47d97

Browse files
Respond to code review feedback
This makes two slight changes after discussing code review feedback: 1. We move the assignment of the @Detections instance variable down below the first guard clause in the Detector::MlCitation initializer. This better accounts for the fact that the Term model implements its own guard clause, resulting in the rest of the application seeing a detector result of null if the detector is not enabled via env vars. 2. Adds a note to the enough_nonzero_values? method comment explaining how we came to decide that three non-zero feature values is sufficient. This includes links to the notebooks where we conducted that analysis.
1 parent 34bfe5e commit fb47d97

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/models/detector/ml_citation.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ class MlCitation
99
# @param phrase String. Often a `Term.phrase`.
1010
# @return Nothing intentional. Data is written to Boolean `@detections` during processing.
1111
def initialize(phrase)
12-
@detections = false
1312
return unless self.class.expected_env?
1413

14+
@detections = false
15+
1516
features = extract_features(phrase)
1617
return unless enough_nonzero_values?(features)
1718

@@ -158,6 +159,11 @@ def fetch(features)
158159

159160
# Enough_nonzero_values? checks that a provided hash contains at least three values which are not zero.
160161
#
162+
# @note We chose 3 as our value here after analyzing the behavior of the citation detector across nearly a year of
163+
# search traffic. For searches which had only one or two features that are not zero, we found no actual citations.
164+
# To see the analyses, look at the "Filtering results" and "Surprising predictions" notebooks at
165+
# https://github.com/MITLibraries/tacos-notebooks/tree/main/notebooks/explorations
166+
#
161167
# @param hash Hash
162168
# @return Integer
163169
def enough_nonzero_values?(hash)

0 commit comments

Comments
 (0)