- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚访问了谷歌的语言支持页面
https://cloud.google.com/natural-language/docs/languages
我发现情绪分析支持阿拉伯语 (ar)。
当我尝试他们提到的教程但使用阿拉伯语句子时,它给了我一个错误,即 ar 不是受支持的语言。
from google.cloud import language_v1
from google.cloud.language_v1 import enums
import os
print(os.environ.get('GOOGLE_APPLICATION_CREDENTIALS'))
def sample_analyze_sentiment(text_content):
"""
Analyzing Sentiment in a String
Args:
text_content The text content to analyze
"""
client = language_v1.LanguageServiceClient()
#text_content = 'I am so happy and joyful.'
# Available types: PLAIN_TEXT, HTML
type_ = enums.Document.Type.PLAIN_TEXT
# Optional. If not specified, the language is automatically detected.
# For list of supported languages:
# https://cloud.google.com/natural-language/docs/languages
language = "ar"
document = {"content": text_content, "type": type_, "language": language}
# Available values: NONE, UTF8, UTF16, UTF32
encoding_type = enums.EncodingType.UTF8
response = client.analyze_sentiment(document, encoding_type=encoding_type)
# Get overall sentiment of the input document
print(u"Document sentiment score: {}".format(response.document_sentiment.score))
print(
u"Document sentiment magnitude: {}".format(
response.document_sentiment.magnitude
)
)
# Get sentiment for all sentences in the document
for sentence in response.sentences:
print(u"Sentence text: {}".format(sentence.text.content))
print(u"Sentence sentiment score: {}".format(sentence.sentiment.score))
print(u"Sentence sentiment magnitude: {}".format(sentence.sentiment.magnitude))
# Get the language of the text, which will be the same as
# the language specified in the request or, if not specified,
# the automatically-detected language.
print(u"Language of the text: {}".format(response.language))
text_content = "اهلا وسهلا"
sample_analyze_sentiment(text_content)
最佳答案
对多种新语言(阿拉伯语、荷兰语、印度尼西亚语、波兰语、泰语、土耳其语、越南语)的支持是 added 2020 年 3 月 20 日,已回滚。关于 supported languages 的文档页面自然语言 API 已更新,不再包含阿拉伯语。因此,截至目前,不支持阿拉伯语。
对所有这些语言的支持预计很快就会出现,但目前没有预计到达时间。
关于python - 使用 Google 进行阿拉伯语情绪分析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60829422/
我正在使用 Solr 以 3 种语言(阿拉伯语、法语和英语)索引文档,我使用了这个 fieldType :
当我在设备(它的语言是阿拉伯语)中运行我的应用程序时,我感到震惊的是,应该在正确方向的对象会向左移动,反之亦然。 后来我意识到是阿拉伯语本地化的自动布局导致了这个问题。 我以编程方式设置自动布局如下:
我想一个字母一个字母地拆分阿拉伯语单词,将它们涂成不同的颜色并在其上添加事件处理程序。 Image, how it looks like 我实现了关于绘画的部分想法,并处理了辅音字母 (harf),但
我关注 this教程,一切都很好,我预处理和训练我的模型但是当我想找到与以下代码的相似之处时: model = gensim.models.Word2Vec.load("wiki.fa.word2ve
我在使用阿拉伯语文本进行变音符号不敏感搜索时遇到问题。 我已经为相关表格测试了多种设置:utf8 和 utf16 编码以及 utf8_general_ci、utf16_general_ci 和 utf
我正在评估 NLTK 在分析和提取情绪的研究中处理阿拉伯文本的能力。 问题如下: NTLK 是否能够处理并允许分析阿拉伯文本? python 是否能够操作\标记阿拉伯文本? 我能否使用 Python
我正在使用 PHPMailer API 发送电子邮件。我想知道如何用阿拉伯语(非英语)发送主题 $mail->CharSet = 'utf-8'; $array= FetchTable('cos
在过去的 15 天或更长时间里,我一直在为一个奇怪的问题而苦苦挣扎。实际上我有一些阿拉伯语文本,但也有一些英文文本。 MY NAME "some arabic text" "some arabic t
我想用阿拉伯语制作一个 flutter 日期选择器,但有一些变化,这是我的代码: locale: Locale('ar', 'MA'), localizationsDelegates: [
我一直在努力为移动应用程序寻找良好的国际日历支持(包括 Hirji)。我的主要限制是 JVM 是 1.3 并且我们只有 AWT。有一个选项可以转移到另一个为我们提供 SWT 的 JVM,但我似乎找不到
我的应用程序是用英语和阿拉伯语两种不同版本开发的。 我在 iText 中使用 rowspan 和 colspan 创建了 pdf 表格,这在英文版中运行良好,但在阿拉伯语版 rowspan 中不起作用
我想将阿拉伯语单词分割成单个字符。基于直方图/配置文件,我假设我可以通过根据其基线(它具有相似的像素值)剪切/分割字符来进行分割过程。 但是,不幸的是,我仍然坚持构建适当的代码,以使其工作。 % Or
我在 JavaScript 函数中遇到了问题 var tDate = new Intl.DateTimeFormat("ar-US", { day: 'numeric', month: 'lo
我已经编写了 java 代码,我希望在 PdfPTable 上显示阿拉伯文字,该 PdfPTable 被用于 itext 文档以创建 PDF 文档 如附图“???”是阿拉伯代码' PdfPTable
简单地说,有没有支持Lucene.Net的Arabic Analyzer。因为我想索引大量的阿拉伯语 txt 文件。我可以使用标准分析器或空白分析器来解析阿拉伯文文件吗? analyzer = new
我正在使用 Vuejs,我想防止输入标签显示用户的字符并将其替换为我自己的字符(这是一些数字)。 我已经在计算中使用了@onchange 和 Watch 以及 getter 和 setter。问题是字
我正在研究 RTL 功能。我从数据库中获取字符串值作为 (f1 (firstname。但我想要 f1 (firstname) 这是我的 javascript 代码。下面的代码运行良好 EN语言。它不仅
我已经下载了阿拉伯语格式的阿拉伯语语言包和编辑器显示,但是当我纠正一些它不是用正确的方向写它总是从左方向开始,阿拉伯语总是从右方向开始但是这是行不通的.. 我的代码——
我使用的是 3.8.2 版本,插入新记录时,utf8 字符串在数据库中显示为问号 (?),但它会正确显示旧记录(使用 phpmyadmin 插入)。 这是我如何初始化 MySQLPool fun in
我有一个阿拉伯语短信模板,其中包含客户支持号码的占位符,并将占位符替换为实际电话号码(例如 +987654400)。替换时加号 (+) 错位在数字末尾,如 987654400+ 示例代码: >>> >
我是一名优秀的程序员,十分优秀!