{ "info": { "author": "XuMing", "author_email": "xuming624@qq.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Natural Language :: Chinese (Simplified)", "Natural Language :: Chinese (Traditional)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Text Processing", "Topic :: Text Processing :: Indexing", "Topic :: Text Processing :: Linguistic" ], "description": "[![PyPI version](https://badge.fury.io/py/pysenti.svg)](https://badge.fury.io/py/pysenti)\n[![License Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/shibing624/pysenti/LICENSE)\n![Language](https://img.shields.io/badge/Language-Python-blue.svg)\n\n\n# pysenti\n\nChinese Sentiment Classification Tool for Python. \u4e2d\u6587\u60c5\u611f\u6781\u6027\u5206\u6790\u5de5\u5177\u3002\n\n**pysenti**\u57fa\u4e8e\u89c4\u5219\u8bcd\u5178\u7684\u60c5\u611f\u6781\u6027\u5206\u6790\uff0c\u6269\u5c55\u6027\u5f3a\uff0c\u53ef\u4f5c\u4e3a\u5de5\u4e1a\u7528\u7684\u57fa\u51c6\u65b9\u6cd5\u3002\n\n\n## \u65b9\u6cd5\n### \u89c4\u5219\u7684\u89e3\u51b3\u601d\u8def\n1. \u4e2d\u6587\u60c5\u611f\u6781\u6027\u5206\u6790\uff0c\u6587\u672c\u5207\u5206\u4e3a\u6bb5\u843d\uff0c\u518d\u5207\u8bcd\uff0c\u901a\u8fc7\u60c5\u611f\u8bcd\u6807\u8bc6\u51fa\u5404\u4e2a\u8bcd\u8bed\u7684\u60c5\u611f\u6781\u6027\uff0c\u5305\u62ec\u79ef\u6781\u3001\u4e2d\u7acb\u3001\u6d88\u6781\u3002\n2. \u7ed3\u5408\u53e5\u5b50\u7ed3\u6784\uff08\u5305\u62ec\u8fde\u8bcd\u3001\u5426\u5b9a\u8bcd\u3001\u526f\u8bcd\u3001\u6807\u70b9\u7b49\uff09\u7ed9\u5404\u60c5\u611f\u8bcd\u8bed\u7684\u60c5\u611f\u6781\u6027\u8d4b\u4e88\u6743\u91cd\uff0c\u7136\u540e\u52a0\u6743\u6c42\u548c\u5f97\u5230\u6587\u672c\u7684\u60c5\u611f\u6781\u6027\u5f97\u5206\u3002\n3. \u4f18\u70b9\uff1a\u6cdb\u5316\u6027\u597d\uff0c\u89c4\u5219\u53ef\u6269\u5c55\u6027\u5f3a\uff0c\u6240\u6709\u9886\u57df\u901a\u7528\u3002\n4. \u7f3a\u70b9\uff1a\u89c4\u5219\u8bcd\u5178\u6536\u96c6\u56f0\u96be\uff0c\u4e13\u5bb6\u7cfb\u7edf\u7684\u6743\u91cd\u8bbe\u5b9a\u6709\u5c40\u9650\uff0c\u5355\u4e00\u9886\u57df\u51c6\u786e\u7387\u76f8\u6bd4\u6a21\u578b\u65b9\u6cd5\u4f4e\u3002\n\n### \u6a21\u578b\u7684\u89e3\u51b3\u601d\u8def\n1. \u5e38\u89c1\u7684[NLP\u6587\u672c\u5206\u7c7b\u6a21\u578b](https://github.com/shibing624/text-classifier)\u5747\u53ef\uff0c\u5305\u62ec\u7ecf\u5178\u6587\u672c\u5206\u7c7b\u6a21\u578b\uff08LR\u3001SVM\u3001Xgboost\u7b49\uff09\u548c\u6df1\u5ea6\u6587\u672c\u5206\u7c7b\u6a21\u578b\uff08TextCNN\u3001Bi-LSTM\u3001BERT\u7b49\uff09\u3002\n2. \u4f18\u70b9\uff1a\u5355\u4e00\u9886\u57df\u51c6\u53ec\u7387\u9ad8\u3002\n3. \u7f3a\u70b9\uff1a\u4e0d\u901a\u7528\uff0c\u6709\u6807\u6ce8\u6570\u636e\u7684\u6837\u672c\u6536\u96c6\u56f0\u96be\uff0c\u6269\u5c55\u6027\u5f31\u3002\n\n## \u7279\u5f81\n### \u89c4\u5219\n* [\u60c5\u611f\u8bcd\u5178](https://github.com/shibing624/pysenti/tree/master/pysenti/data)\u6574\u5408\u4e86`\u77e5\u7f51\u60c5\u611f\u8bcd\u5178`\u3001`\u6e05\u534e\u5927\u5b66\u674e\u519b\u60c5\u611f\u8bcd\u5178`\u3001[BosonNLP\u60c5\u611f\u8bcd\u5178](https://bosonnlp.com/dev/resource)\u3001`\u5426\u5b9a\u8bcd\u8bcd\u5178`\u3002\n\n### \u6a21\u578b\n* bayes \u6587\u672c\u5206\u7c7b\u6a21\u578b\n* [\u6837\u672c\u6570\u636e](https://github.com/shibing624/pysenti/tree/master/pysenti/data)\u6765\u81ea\u5546\u54c1\u8bc4\u8bba\u6570\u636e\uff0c\u5206\u4e3a\u79ef\u6781\u3001\u6d88\u6781\u4e24\u7c7b\u3002\n\n## demo\n\nhttps://www.borntowin.cn/product/sentiment_classify\n\n\n## \u5b89\u88c5\n* \u5168\u81ea\u52a8\u5b89\u88c5\uff1apip3 install pysenti\n* \u534a\u81ea\u52a8\u5b89\u88c5\uff1a\n```\ngit clone https://github.com/shibing624/pysenti.git\ncd pysenti\npython3 setup.py install\n```\n\n## \u4f7f\u7528\u793a\u4f8b\n### \u89c4\u5219\u65b9\u6cd5\n```\nimport pysenti\n\ntexts = [\"\u82f9\u679c\u662f\u4e00\u5bb6\u4f1f\u5927\u7684\u516c\u53f8\",\n \"\u571f\u8c46\u4e1d\u5f88\u597d\u5403\",\n \"\u571f\u8c46\u4e1d\u5f88\u96be\u5403\"]\nfor i in texts:\n r = pysenti.classify(i)\n print(i, r['score'], r)\n\n```\n\noutput:\n```\n\u82f9\u679c\u662f\u4e00\u5bb6\u4f1f\u5927\u7684\u516c\u53f8 3.4346924811096997 {'score': 3.4346924811096997, 'sub_clause0': {'score': 3.4346924811096997, 'sentiment': [{'key': '\u82f9\u679c', 'adverb': [], 'denial': [], 'value': 1.37846341627, 'score': 1.37846341627}, {'key': '\u662f', 'adverb': [], 'denial': [], 'value': -0.252600480826, 'score': -0.252600480826}, {'key': '\u4e00\u5bb6', 'adverb': [], 'denial': [], 'value': 1.48470161748, 'score': 1.48470161748}, {'key': '\u4f1f\u5927', 'adverb': [], 'denial': [], 'value': 1.14925252286, 'score': 1.14925252286}, {'key': '\u7684', 'adverb': [], 'denial': [], 'value': 0.0353323193687, 'score': 0.0353323193687}, {'key': '\u516c\u53f8', 'adverb': [], 'denial': [], 'value': -0.360456914043, 'score': -0.360456914043}], 'conjunction': []}}\n\u571f\u8c46\u4e1d\u5f88\u597d\u5403 2.294311221077 {'score': 2.294311221077, 'sub_clause0': {'score': 2.294311221077, 'sentiment': [{'key': '\u571f\u8c46\u4e1d', 'adverb': [], 'denial': [], 'value': 0.294892711165, 'score': 0.294892711165}, {'key': '\u5f88', 'adverb': [], 'denial': [], 'value': 0.530242664632, 'score': 0.530242664632}, {'key': '\u597d\u5403', 'adverb': [], 'denial': [], 'value': 1.46917584528, 'score': 1.46917584528}], 'conjunction': []}}\n\u571f\u8c46\u4e1d\u5f88\u96be\u5403 -2.381874203563 {'score': -2.381874203563, 'sub_clause0': {'score': -2.381874203563, 'sentiment': [{'key': '\u571f\u8c46\u4e1d', 'adverb': [], 'denial': [], 'value': 0.294892711165, 'score': 0.294892711165}, {'key': '\u5f88', 'adverb': [], 'denial': [], 'value': 0.530242664632, 'score': 0.530242664632}, {'key': '\u96be\u5403', 'adverb': [], 'denial': [], 'value': -3.20700957936, 'score': -3.20700957936}], 'conjunction': []}}\n```\n> score: \u6b63\u503c\u662f\u79ef\u6781\u60c5\u611f\uff1b\u8d1f\u503c\u662f\u6d88\u6781\u60c5\u611f\u3002\n\n### \u6a21\u578b\u65b9\u6cd5\n\n\n```\nfrom pysenti import model_classifier\n\ntexts = [\"\u82f9\u679c\u662f\u4e00\u5bb6\u4f1f\u5927\u7684\u516c\u53f8\",\n \"\u571f\u8c46\u4e1d\u5f88\u597d\u5403\",\n \"\u571f\u8c46\u4e1d\u5f88\u96be\u5403\"]\nfor i in texts:\n result = model_classifier.classify(i)\n print(i, result)\n\n```\n\noutput\uff1a\n```\n\u82f9\u679c\u662f\u4e00\u5bb6\u4f1f\u5927\u7684\u516c\u53f8 {'positive_prob': 0.682, 'negative_prob': 0.318}\n\u571f\u8c46\u4e1d\u5f88\u597d\u5403 {'positive_prob': 0.601, 'negative_prob': 0.399}\n\u571f\u8c46\u4e1d\u5f88\u96be\u5403 {'positive_prob': 0.283, 'negative_prob': 0.717}\n\n```\n\n### \u547d\u4ee4\u884c\n\n\u4f7f\u7528\u793a\u4f8b\uff1a python -m pysenti news.txt > news_result.txt\n\n\u547d\u4ee4\u884c\u9009\u9879\uff08\u7ffb\u8bd1\uff09\uff1a\n```\n\u4f7f\u7528: python -m pysenti [options] filename\n\n\u547d\u4ee4\u884c\u754c\u9762\n\n\u56fa\u5b9a\u53c2\u6570:\n filename \u8f93\u5165\u6587\u4ef6\n\n\u53ef\u9009\u53c2\u6570:\n -h, --help \u663e\u793a\u6b64\u5e2e\u52a9\u4fe1\u606f\u5e76\u9000\u51fa\n -d DICT, --dict DICT \u4f7f\u7528 DICT \u4ee3\u66ff\u9ed8\u8ba4\u8bcd\u5178\n -u USER_DICT, --user-dict USER_DICT\n \u4f7f\u7528 USER_DICT \u4f5c\u4e3a\u9644\u52a0\u8bcd\u5178\uff0c\u4e0e\u9ed8\u8ba4\u8bcd\u5178\u6216\u81ea\u5b9a\u4e49\u8bcd\u5178\u914d\u5408\u4f7f\u7528\n -a, --output-all \u8f93\u51fa\u53e5\u5b50\u53ca\u8bcd\u7ea7\u522b\u60c5\u611f\u5206\u6790\u8be6\u7ec6\u4fe1\u606f\n -V, --version \u663e\u793a\u7248\u672c\u4fe1\u606f\u5e76\u9000\u51fa\n\n\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u6587\u4ef6\u540d\uff0c\u5219\u4f7f\u7528\u6807\u51c6\u8f93\u5165\u3002\n```\n\n\n`--help`\u9009\u9879\u8f93\u51fa\uff1a\n```\n$> python -m jieba --help\n\nusage: python3 -m pysenti [options] filename\n\npysenti command line interface.\n\npositional arguments:\n filename input file\n\noptional arguments:\n -h, --help show this help message and exit\n -d DICT, --dict DICT use DICT as dictionary\n -u USER_DICT, --user-dict USER_DICT\n use USER_DICT together with the default dictionary or\n DICT (if specified)\n -a, --output-all output text sentiment score and word sentiment info\n -V, --version show program's version number and exit\n\nIf no filename specified, use STDIN instead.\n```\n\n### \u5ef6\u8fdf\u52a0\u8f7d\u673a\u5236\n\npysenti \u91c7\u7528\u5ef6\u8fdf\u52a0\u8f7d\uff0c`import pysenti` \u548c ``\u548c `from pysenti import rule_classifier` \u4e0d\u4f1a\u7acb\u5373\u89e6\u53d1\u8bcd\u5178\u7684\u52a0\u8f7d\uff0c\u4e00\u65e6\u6709\u5fc5\u8981\u624d\u5f00\u59cb\u52a0\u8f7d\u8bcd\u5178\u3002\u5982\u679c\u4f60\u60f3\u624b\u5de5\u521d\u59cb pysenti\uff0c\u4e5f\u53ef\u4ee5\u624b\u52a8\u521d\u59cb\u5316\u3002\n```\nimport pysenti\npysenti.rule_classifier.init() # \u624b\u52a8\u521d\u59cb\u5316\uff08\u53ef\u9009\uff09\n```\n\n\u6709\u4e86\u5ef6\u8fdf\u52a0\u8f7d\u673a\u5236\u540e\uff0c\u4f60\u53ef\u4ee5\u6539\u53d8\u4e3b\u8bcd\u5178\u7684\u8def\u5f84:\n```\npysenti.rule_classifier.init('data/sentiment_dict.txt')\n\n```\n\n## \u611f\u8c22\n\n1. snownlp\n2. SentimentPolarityAnalysis", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/shibing624/pysenti", "keywords": "NLP,sentiment-classifier,sentiment-classification,pysenti", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "pysenti", "package_url": "https://pypi.org/project/pysenti/", "platform": "", "project_url": "https://pypi.org/project/pysenti/", "project_urls": { "Homepage": "https://github.com/shibing624/pysenti" }, "release_url": "https://pypi.org/project/pysenti/0.1.6/", "requires_dist": null, "requires_python": "", "summary": "Chinese Sentiment Classifier", "version": "0.1.6" }, "last_serial": 5868237, "releases": { "0.1.3": [ { "comment_text": "", "digests": { "md5": "47a15bf1a52994ea3899ef62752515a4", "sha256": "a7edea4d4368e7846faa5f118b53f612cc0bcf720eff7fe6177b7bf8e8cacd83" }, "downloads": -1, "filename": "pysenti-0.1.3.tar.gz", "has_sig": false, "md5_digest": "47a15bf1a52994ea3899ef62752515a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4694796, "upload_time": "2019-09-22T03:01:33", "url": "https://files.pythonhosted.org/packages/c7/ad/330a0104410f712684c1409134e92d2a939986773af133b0de6990dc0f66/pysenti-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "4c30786a2bd7f2b415d2aa5899d2b79c", "sha256": "630735aea209c779176e1d2f264ab231701927f00f2ec9513cc8de705bd532ec" }, "downloads": -1, "filename": "pysenti-0.1.4.tar.gz", "has_sig": false, "md5_digest": "4c30786a2bd7f2b415d2aa5899d2b79c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4704525, "upload_time": "2019-09-22T05:01:38", "url": "https://files.pythonhosted.org/packages/12/4c/45ccbb866326cb4558c3659d87e9a14b5cb8d0ba4df87fd63777c700e4f2/pysenti-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "b40d8d1c51d1fc75f0aa7dd8fd42bc84", "sha256": "4f4e98dca553791bbcff89bad48c0fd088681af9b37dc200d0a18b3c08122f36" }, "downloads": -1, "filename": "pysenti-0.1.5.tar.gz", "has_sig": false, "md5_digest": "b40d8d1c51d1fc75f0aa7dd8fd42bc84", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4706230, "upload_time": "2019-09-22T06:05:42", "url": "https://files.pythonhosted.org/packages/cc/00/fb93e488761ae64b88c660fe15f0abffe35407eb890f8a2796bd16f8ad53/pysenti-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "e9e936902b74b68ae3af6eb0938366ab", "sha256": "3fef2cc8b84949ec182a060c672cc103a181e4061682e79dc2a274825e052005" }, "downloads": -1, "filename": "pysenti-0.1.6.tar.gz", "has_sig": false, "md5_digest": "e9e936902b74b68ae3af6eb0938366ab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4706211, "upload_time": "2019-09-22T07:50:45", "url": "https://files.pythonhosted.org/packages/74/e0/dd649304053998f19317d2a0026b5bb4d4e0979ebf2a60ea3e8b187ecdb0/pysenti-0.1.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e9e936902b74b68ae3af6eb0938366ab", "sha256": "3fef2cc8b84949ec182a060c672cc103a181e4061682e79dc2a274825e052005" }, "downloads": -1, "filename": "pysenti-0.1.6.tar.gz", "has_sig": false, "md5_digest": "e9e936902b74b68ae3af6eb0938366ab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4706211, "upload_time": "2019-09-22T07:50:45", "url": "https://files.pythonhosted.org/packages/74/e0/dd649304053998f19317d2a0026b5bb4d4e0979ebf2a60ea3e8b187ecdb0/pysenti-0.1.6.tar.gz" } ] }