EmotionAnalyzer
public class EmotionAnalyzer
Class to extract the sentiments from a text.
It is a good idea to test that the model is loaded before calling analyze(). A simple use case to analyze a text for prevalent emotions would be:
func classifyText(text: String) -> EmotionResult? {
if (EmotionAnalyzer.sharedInstance().isLoaded()) {
return EmotionAnalyzer.sharedInstance().analyze(text: text)
}
return nil
}
-
Class function to get the single instance of this class.
Declaration
Swift
public class func sharedInstance() -> EmotionAnalyzer
Return Value
The singleton instance of the class.
-
Initialise the emotion analyzer.
Declaration
Swift
public func initManager()
-
Check whether the model has been initialised or not.
Declaration
Swift
public func isLoaded() -> Bool
Return Value
true
if the model is loaded. -
Analyze a text for emotion.
Declaration
Swift
public func analyze(text: String) -> EmotionResult?
Parameters
text
The text to analyze.
Return Value
A mapping of emotion to score. Higher score means more prevalence of the associated emotion.