someben/treebank
someben/treebank has 40 GitHub stars and 8 forks. Star changes are not measured yet. Last checked 2026-11-14 04:18 UTC. Last push 2026-10-13.
측정된 스타 증가
- in 24h
- 기록 수집 중
- in 7 days
- 기록 수집 중
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
소개
Ruby loader for the Stanford Sentiment Treebank (SST) parse trees and phrase labels, plus a locality-sensitive-hash index for word2vec binaries
머신러닝README.md
Originaltreebank
Ruby tools for the Stanford Sentiment Treebank (SST, Socher et al. 2013) and for indexing binary word2vec models. Written in 2013, the year both came out.
The SST labels every phrase in 11,855 movie-review sentences with a sentiment score between 0 (very negative) and 1 (very positive). It ships as five pipe-delimited files plus a parent-pointer encoding of each parse tree. This library joins those files back into trees you can walk.
What's here
| File | What it does |
|---|---|
src/_stanford_sentiment_treebank.rb |
Loads the SST, rebuilds each sentence's parse tree, and yields phrase-to-sentiment maps. Optionally renders every tree to SVG with nodes shaded by sentiment. |
src/build_word2vec_index.rb |
Reads a binary word2vec .bin file and writes a JSON index of each word's byte offset and a 10-bit locality-sensitive hash (random hyperplane projections), so you can seek to one vector or find near neighbours without loading the model into memory. |
src/run_tests.rb |
Test::Unit checks against the first SST sentence. |
Setup
gem install ruby-graphviz gsl # gsl needs the GNU Scientific Library: apt install libgsl-dev
curl -LO https://nlp.stanford.edu/~socherr/stanfordSentimentTreebank.zip
unzip stanfordSentimentTreebank.zip -d ~
The loader expects the data in ~/stanfordSentimentTreebank/ (dictionary.txt,
sentiment_labels.txt, SOStr.txt, STree.txt). Change DATA_DIR to move it.
Usage
$LOAD_PATH.unshift "src"
require "_logger"
require "_stanford_sentiment_treebank"
tb = StanfordSentimentTreebank::StanfordSentimentTreebank.new(10) # first 10 sentences
tb.each_phrase_map do |phrases|
phrases.each { |phrase, score| puts format("%.3f %s", score, phrase) }
end
For the first sentence this prints 69 phrases, including
0.583 destined and 0.542 even greater.
To walk the trees yourself, each_node_map yields (node_map, tokens), where
node_map maps each node number to its children and node 0 is the root.
each_node_map_leaf_trigram yields every parent whose two children are both
words, which is the smallest unit where composition changes sentiment.
With IS_GRAPHING = true (the default), each tree is also written to your temp
directory as stanford_treebank_phraseNNNNNNNN.svg, grey-shaded from black
(negative) to white (positive). Set it to false for bulk runs.
word2vec index
ruby -I src src/build_word2vec_index.rb GoogleNews-vectors-negative300.bin
# writes GoogleNews-vectors-negative300.bin.idx
The projection dimension is set to 1,000 in the script; change it to the model's layer size (300 for the GoogleNews vectors) before running.
Tests
ruby -I src src/run_tests.rb
License
Apache 2.0. Ben Gimpert, Something Modern. More at blog.someben.com.
관련 프로젝트 살펴보기
tensorflow/tensorflow
모두를 위한 오픈소스 머신러닝 프레임워크
201,590 스타huggingface/transformers
🤗 Transformers: 텍스트, 비전, 오디오, 멀티모달 분야의 최첨단 머신러닝 모델을 위한 모델 정의 프레임워크로, 추론과 학습을 모두 지원합니다.
168,957 스타AUTOMATIC1111/stable-diffusion-webui
Stable Diffusion 웹 UI
165,307 스타Comfy-Org/ComfyUI
그래프와 노드로 구성된 인터페이스를 갖춘, 가장 강력하고 모듈성이 뛰어난 확산 모델 GUI, API, 백엔드입니다. 세계에서 가장 빠른 로컬 추론 엔진입니다.
146,728 스타