Created
March 10, 2023 17:15
-
-
Save matheusruschel/5070ac57d696093b9f5013bd868c3e91 to your computer and use it in GitHub Desktop.
ReviewClassifier.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CoreML | |
import NaturalLanguage | |
class ReviewClassifier { | |
let model: NLModel | |
init() { | |
let modelURL = Bundle.main.url(forResource: "ReviewModel", withExtension: "mlmodelc")! | |
model = try! NLModel(contentsOf: modelURL) | |
} | |
func classifyReview(text: String) -> String { | |
let classification = model.predictedLabel(for: text) | |
print("Classification: \(classification)") | |
return classification | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment