I'm using a list of words with positive and negative sentiment from AFINN to do some text analysis.
Problem is, the list comes in a .txt file in the following format (word on the left, pos vs neg index at right):
casualty -2
catastrophe -3
catastrophic -4
cautious -1
celebrate 3
celebrated 3
celebrates 3
celebrating 3
To work with it, I need it in the following format:
var array = [{word:"casualty",score:-2},{word:"catastrophe",score:-3},{word:"catastrophic",score:-4}, etc etc]
I'd actually prefer to do this once with a shell script, rather than in the browser. Which is why I'm thinking Node.js could come in handy here. But I'm not very familiar with Node.
如果您不太在乎如何将文本读入javascript数组,而您只需要JSON中的AFINN,我在这里找到了一个版本。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.