Skip to content

Instantly share code, notes, and snippets.

@anupamchugh
Created November 9, 2019 04:48
Show Gist options
  • Save anupamchugh/10c232465f045c56b46a932e11f7b705 to your computer and use it in GitHub Desktop.
Save anupamchugh/10c232465f045c56b46a932e11f7b705 to your computer and use it in GitHub Desktop.
class ResultsObserver: NSObject, SNResultsObserving {
var delegate: GenderClassifierDelegate?
func request(_ request: SNRequest, didProduce result: SNResult) {
guard let result = result as? SNClassificationResult,
let classification = result.classifications.first else { return }
let confidence = classification.confidence * 100.0
if confidence > 60 {
delegate?.displayPredictionResult(identifier: classification.identifier, confidence: confidence)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment