Skip to content

Instantly share code, notes, and snippets.

@fitomad
Last active September 28, 2018 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitomad/5e21fd60e3685f8e6b6851f5b813e3cf to your computer and use it in GitHub Desktop.
Save fitomad/5e21fd60e3685f8e6b6851f5b813e3cf to your computer and use it in GitHub Desktop.
import NaturalLanguage
...
/**
Consulta al modelo acerca de la categoría a la
que pertenece la reseña que acaba de escribir el
usuario.
*/
@IBAction private func handlePredictButtoTap(sender: UIButton) -> Void
{
self.labelRating.text = ""
guard let model = try? NLModel(mlModel: SentimentReview().model),
let review = self.textviewReview.text
else
{
return
}
if let rating = model.predictedLabel(for: review), let rate = Rate(rawValue: rating)
{
self.labelRating.text = "(\(rating))\(rate)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment