我正在与 Watson NLU 合作并尝试对某些文本进行情感分析。问题是某些文本太小,无法检测到它是什么语言(例如:优质的服务)。有没有办法让我指定如果无法进行语言检测,则应将其视为英语?
我的 NLU (Java) 的片段是这样的:
SentimentOptions sentiment = new SentimentOptions.Builder()
.targets(targets)
.document(true)
.build();
Features features = new Features.Builder()
.sentiment(sentiment)
.build();
AnalyzeOptions parameters = new AnalyzeOptions.Builder()
.text(text)
.features(features)
.build();
AnalysisResults response = service
.analyze(parameters)
.execute();
String mySentiment = response.getSentiment().getDocument().getLabel();
Run Code Online (Sandbox Code Playgroud) 我正在使用自然语言理解 api。我正在使用“hmmmm nawa ohh wen am I gona win dstin”,但出现错误
WatsonException: Error: unsupported text language, Code: 400
Run Code Online (Sandbox Code Playgroud)
我的代码是:
response = natural_language_understanding.analyze(
text='hmmmm nawa ohh wen am I gona win ds tin',
features=[features.Sentiment(), features.Keywords(), features.Emotion(), features.Categories()])
Run Code Online (Sandbox Code Playgroud)
如何将这些类型的文本传递给 NLU api。需要帮忙。