pytreebank

所属分类:数据可视化
开发工具:Python
文件大小:145KB
下载次数:0
上传日期:2020-02-18 06:05:24
上 传 者sh-1993
说明:  Python中的斯坦福情感树库加载程序
(Stanford Sentiment Treebank loader in Python)

文件列表:
.travis.yml (353, 2020-02-18)
LICENSE.md (1082, 2020-02-18)
MANIFEST.in (89, 2020-02-18)
examples (0, 2020-02-18)
examples\scrape.py (410, 2020-02-18)
pytreebank (0, 2020-02-18)
pytreebank\__init__.py (177, 2020-02-18)
pytreebank\box_office.py (1830, 2020-02-18)
pytreebank\download.py (2048, 2020-02-18)
pytreebank\javascript (0, 2020-02-18)
pytreebank\javascript\__init__.py (1706, 2020-02-18)
pytreebank\javascript\c3.min.js (6408, 2020-02-18)
pytreebank\javascript\d3.min.js (42799, 2020-02-18)
pytreebank\javascript\sentree.min.js (23966, 2020-02-18)
pytreebank\javascript\sentrees.min.js (7118, 2020-02-18)
pytreebank\javascript\tree_visualization.css (3904, 2020-02-18)
pytreebank\javascript\tree_visualization.js (456, 2020-02-18)
pytreebank\labeled_trees.py (6676, 2020-02-18)
pytreebank\parse.py (6305, 2020-02-18)
pytreebank\treelstm.py (2983, 2020-02-18)
pytreebank\utils.py (1988, 2020-02-18)
release.sh (191, 2020-02-18)
setup.py (1070, 2020-02-18)
tests (0, 2020-02-18)
tests\test_download.zip (1042, 2020-02-18)
tests\test_load.py (3640, 2020-02-18)
visualization_example.png (129980, 2020-02-18)

SST Utils --------- Utilities for downloading, importing, and visualizing the [Stanford Sentiment Treebank](http://nlp.stanford.edu/sentiment/treebank.html), a dataset capturing fine-grained sentiment over movie reviews. See examples below for usage. Tested in Python `3.4.3` and `2.7.12`. ![Jonathan Raiman, author](https://img.shields.io/badge/Author-Jonathan%20Raiman%20-blue.svg) Javascript code by Jason Chuang and Stanford NLP modified and taken from [Stanford NLP Sentiment Analysis demo](http://nlp.stanford.edu:8080/sentiment/rntnDemo.html). [![PyPI version](https://badge.fury.io/py/pytreebank.svg)](https://badge.fury.io/py/pytreebank) [![Build Status](https://travis-ci.org/JonathanRaiman/pytreebank.svg?branch=master)](https://travis-ci.org/JonathanRaiman/pytreebank) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md) ### Visualization Allows for visualization using Jason Chuang's Javascript and CSS within an IPython notebook: ```python import pytreebank # load the sentiment treebank corpus in the parenthesis format, # e.g. "(4 (2 very ) (3 good))" dataset = pytreebank.load_sst() # add Javascript and CSS to the Ipython notebook pytreebank.LabeledTree.inject_visualization_javascript() # select and example to visualize example = dataset["train"][0] # display it in the page example.display() ``` ![Example visualization using pytreebank](visualization_example.png) ### Lines and Labels To use the corpus to output spans from the different trees you can call the `to_labeled_lines` and `to_lines` method of a `LabeledTree`. The first returned sentence in those lists is always the root sentence: ```python import pytreebank dataset = pytreebank.load_sst() example = dataset["train"][0] # extract spans from the tree. for label, sentence in example.to_labeled_lines(): print("%s has sentiment label %s" % ( sentence, ["very negative", "negative", "neutral", "positive", "very positive"][label] )) ``` ### Download/Loading control: Change the save/load directory by passing a path (this will look for `train.txt`, `dev.txt` and `test.txt` files under the directory). ``` dataset = pytreebank.load_sst("/path/to/sentiment/") ``` To just load a single dataset file: ``` train_data = pytreebank.import_tree_corpus("/path/to/sentiment/train.txt") ```

近期下载者

相关文件


收藏者