我发现了一个非常酷的NLP API,可以使用特殊技能来分析文本。然而,我是Python新手,不知道如何获取输出。有人能帮帮我吗?这是我尝试过的内容:
# Edit this One AI API call using our studio at https://studio.oneai.com/?pipeline=nGM7cx# pip install oneaiimport oneaioneai.api_key = "INSERT_API_KEY"text = 'Natural language processing (NLP) is a subfield of linguistics, computer science, and artificial intelligence concerned with the interactions between computers and human language, in particular how to program computers to process and analyze large amounts of natural language data. The goal is a computer capable of "understanding" the contents of documents, including the contextual nuances of the language within them. The technology can then accurately extract information and insights contained in the documents as well as categorize and organize the documents themselves. Challenges in natural language processing frequently involve speech recognition, natural language understanding, and natural language generation. Based on long-standing trends in the field, it is possible to extrapolate future directions of NLP. As of 2020, three trends among the topics of the long-standing series of CoNLL Shared Tasks can be observed: Interest on increasingly abstract, "cognitive" aspects of natural language, Increasing interest in multilinguality and Elimination of symbolic representations.'pipeline = oneai.Pipeline( steps=[ oneai.skills.Highlights(), oneai.skills.Topics(), oneai.skills.Summarize(), ])output = pipeline.run(text)
回答:
看起来你的代码是有效的。所以你需要做的唯一一件事就是打印pipeline。只需在你的代码末尾添加以下一行:
print(output)
这是修改后的代码:
# Edit this One AI API call using our studio at https://studio.oneai.com/?pipeline=nGM7cx# pip install oneaiimport oneaioneai.api_key = "INSERT_API_KEY"text = 'Natural language processing (NLP) is a subfield of linguistics, computer science, and artificial intelligence concerned with the interactions between computers and human language, in particular how to program computers to process and analyze large amounts of natural language data. The goal is a computer capable of "understanding" the contents of documents, including the contextual nuances of the language within them. The technology can then accurately extract information and insights contained in the documents as well as categorize and organize the documents themselves. Challenges in natural language processing frequently involve speech recognition, natural language understanding, and natural language generation. Based on long-standing trends in the field, it is possible to extrapolate future directions of NLP. As of 2020, three trends among the topics of the long-standing series of CoNLL Shared Tasks can be observed: Interest on increasingly abstract, "cognitive" aspects of natural language, Increasing interest in multilinguality and Elimination of symbolic representations.'pipeline = oneai.Pipeline( steps=[ oneai.skills.Highlights(), oneai.skills.Topics(), oneai.skills.Summarize(), ])output = pipeline.run(text)print(output)
请确保从oneai工作室获取你的API密钥。如oneai的文档中提到的 – https://docs.oneai.com/docs/quick-start
另外,请确保使用 pip install oneai
安装oneai。