나는이 대답을 따랐다 : Stanford nlp for python
from pycorenlp import StanfordCoreNLP
from newspaper import Article
url = u'newsArticle.example.html'
nlp = StanfordCoreNLP('http://localhost:9000')
article = Article(url)
article.download()
article.parse()
LARGE_TEXT=article.text
res = nlp.annotate(LARGE_TEXT,
properties={
'annotators': 'sentiment',
'outputFormat': 'json',
'timeout': 1000,
})
for s in res["sentences"]:
print ("%d: '%s': %s %s" % (
s["index"],
" ".join([t["word"] for t in s["tokens"]]),
s["sentimentValue"], s["sentiment"]))
더 긴 텍스트를 입력으로 사용했고 다음 오류가 발생했습니다.
for s in res["sentences"]:
TypeError: string indices must be integers
문제는 '시간 초과': 1000입니다.
나는 그것을 'timeout': 10000으로 변경했습니다 .
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다