项目作者: itsamayo

项目描述 :
An NPM package for analyzing strings based on sentiment and keyword strength using synonyms sentiment analysis
高级语言: JavaScript
项目地址: git://github.com/itsamayo/sentiment-and-keyword.git
创建时间: 2019-10-17T21:15:00Z
项目社区:https://github.com/itsamayo/sentiment-and-keyword

开源协议:

下载


sentiment-and-keyword

See https://www.npmjs.com/package/sentiment-and-keyword

Install

npm i sentiment-and-keyword

Usage

  1. const sentkey = require('sentiment-and-keyword');
  2. // Set your text to analyzed *required
  3. let text = "The text you want to be analyzed";
  4. // Set your keywords to be used for analysis *required
  5. let keywords = ["Independent", "Honest", "Collaborative", "Brilliant", "Caring"];
  6. sentkey.analyze(text,keywords,function(err,res){
  7. if(err){
  8. console.log(err);
  9. return
  10. }
  11. console.log(res);
  12. })

Result parse

  1. {
  2. "text": "The text you want to be analyzed",
  3. "sentiment_score": 0,
  4. "sentiment_status": "Neutral",
  5. "sentiment_calculation": [
  6. {"Independent": 0},
  7. {"Honest": 0},
  8. {"Collaborative": 0},
  9. {"Brilliant": 0},
  10. {"Caring": 0}
  11. ],
  12. "sentiment_comparative": "0",
  13. "strength_tracker": [
  14. {"keyword": "Independent", "score": 0},
  15. {"keyword": "Honest", "score": 0},
  16. {"keyword": "Collaborative", "score": 0},
  17. {"keyword": "Brilliant", "score": 0},
  18. {"keyword": "Caring", "score": 0}
  19. ],
  20. "graph_data": [
  21. [
  22. "Keyword",
  23. "Percentage",
  24. { "role": "style" }
  25. ],
  26. ["keyword1", 0, "#color"],
  27. ["keyword3", 0, "#color"],
  28. ["keyword4", 0, "#color"],
  29. ["keyword5", 0, "#color"],
  30. ["keyword6", 0, "#color"],
  31. ]
  32. };