简体   繁体   English

在 output 上创建一个字符串。 output 是 NoneType object

[英]Create a string on the output. The output is a NoneType object

I am running Aspect-Based-Sentiment-Analysis.我正在运行基于方面的情绪分析。 And I get the output.我得到了 output。 I want to get this output as a string.我想把这个 output 作为一个字符串。 I spent several hours in googling how to refer to the output and not only to see the output when I run a code.我花了几个小时在谷歌上搜索如何引用 output 而不仅仅是在运行代码时看到 output。 Maybe I don't comprehend something in Python basics and need huge support on that.也许我不理解 Python 基础知识中的某些内容,因此需要大量支持。

The code I am talking about is as follows:我正在谈论的代码如下:

absa.summary(money)

The output that i receive from this code:我从此代码收到的 output:

Sentiment.positive for "money"
Scores (neutral/negative/positive): [0.001 0.006 0.993]
None

I checked the type of this object and it says Nonetype:我检查了这个 object 的类型,它说 Nonetype:

type(absa.summary(money))
Sentiment.positive for "money"
Scores (neutral/negative/positive): [0.001 0.006 0.993]
NoneType

How can I extract the text from the output as a string?如何从 output 中提取文本作为字符串? Any ideas?有任何想法吗? I will provide any additional info when it is needed.我会在需要时提供任何其他信息。

Looks like the command is just printing the output to stdout instead of acutally returning an object containing the information you are looking for.看起来该命令只是将 output 打印到stdout ,而不是实际返回包含您要查找的信息的 object。 You may want to try and capture stdout while running the function.您可能想在运行 function 时尝试捕获stdout The answer to this question should be helpful. 这个问题的答案应该会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM