我正在尝试使用 Google Cloud Natural Language API 对推文进行分类/分类,以过滤掉与我的受众无关的推文(与天气相关)。我可以理解,人工智能解决方案对少量文本进行分类肯定很棘手,但我想它至少会对这样的文本进行猜测:
在早上 6 点到 9 点期间,预计阿肯色州西北部到阿肯色州中北部的寒风将达到零到 -5 度,并延伸到俄克拉荷马州北部的部分地区。#arwx #okwx
我已经测试了几条推文,但只有极少数得到了分类,其余的没有结果(或“未找到类别。尝试更长的文本输入。”如果我通过GUI尝试)。
希望这能奏效是不是毫无意义?或者,是否可以降低分类的阈值?来自 NLP 解决方案的“有根据的猜测”总比没有过滤器要好。是否有替代解决方案(除了训练我自己的 NLP 模型)?
编辑:为了澄清:
最后,我使用谷歌云平台自然语言 API 来对推文进行分类。为了测试它,我正在使用 GUI(上面链接)。我可以看到我测试(在 GUI 中)的推文中很少有从 GCP NLP 获得分类,即类别是空的。
我想要的理想状态是让 GCP NLP 提供推文文本的类别猜测,而不是提供空结果。我假设 NLP 模型会删除任何置信度低于 X% 的结果。知道是否可以配置该阈值会很有趣。
我认为之前必须对推文进行分类,如果有任何其他方法可以解决这个问题?
编辑 2:分类推文代码:
async function classifyTweet(tweetText) {
const language = require('@google-cloud/language');
const client = new language.LanguageServiceClient({projectId, keyFilename});
//const tweetText = "Some light snow dusted the ground this morning, adding to the intense snow fall of yesterday. Here at my Warwick station the numbers are in, New Snow 19.5cm and total depth 26.6cm. A very good snow event. Photos to be posted. #ONStorm #CANWarnON4464 #CoCoRaHSON525"
const document = {
content: tweetText,
type: 'PLAIN_TEXT',
};
const [classification] = await client.classifyText({document});
console.log('Categories:');
classification.categories.forEach(category => {
console.log(`Name: ${category.name}, Confidence: ${category.confidence}`);
});
return classification.categories
}