Skip to content

Commit 9e43e1f

Browse files
committed
Working update of README
1 parent 9a5e0f0 commit 9e43e1f

File tree

1 file changed

+29
-32
lines changed

1 file changed

+29
-32
lines changed

README.md

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# sentR
2-
A continually developed R package to provide functional sentiment analysis utility.
2+
An R package that provide functional sentiment analysis utilities.
33

44
## Install
55

@@ -8,43 +8,40 @@ A continually developed R package to provide functional sentiment analysis utili
88
2. Require devtools: run `require('devtools')`
99
3. Install sentR@latest: run `install_github('mananshah99/sentR')`
1010

11-
## Sentiment Scoring Functions
11+
# Sentiment Scoring Examples
1212

13-
### score.aggregate = function(sentences, pos.words, neg.words, .progress='none')
14-
Scores the sentiment of text by setting words in `pos.words` to `+1` and words in `neg.words` to `-1` in the vector of sentences.
13+
Input:
1514

16-
Example:
1715
```
1816
require('sentR')
19-
positive <- c('happy', 'well-off', 'good')
20-
negative <- c('sad', 'bad', 'miserable', 'terrible')
21-
test <- c('I am a very happy person.', 'I am a very sad person', 'R has good data analysis tools')
22-
out <- score.aggregate(test, positive, negative)
23-
out
24-
```
25-
Output:
26-
```
27-
score text
28-
1 1 I am a very happy person.
29-
2 -1 I am a very sad person
30-
3 1 R has good data analysis tools
31-
```
32-
33-
### score.naivebayes = function(train.sentences, test.sentences, .progress = 'none')
34-
Scores the sentiment of text by using the Naive Bayes modeling functionality from `e1071`.
3517
36-
### score.viralheat = function (text, api.key)
37-
Scores the sentiment of text using the ViralHeat API (requires an API key)
38-
39-
## Sentiment Scraping Utilities
18+
# Create small vectors for happy and sad words (useful in aggregate(...) function)
19+
positive <- c('happy', 'well-off', 'good', 'happiness')
20+
negative <- c('sad', 'bad', 'miserable', 'terrible')
4021
41-
### scrape.IMDb <- function(url)
42-
Scrapes the IMDb website for movie reviews and returns a list of scores.
22+
# Words to test sentiment
23+
test <- c('I am a very happy person.', 'I am a very sad person',
24+
'I’ve always understood happiness to be appreciation. There is no greater happiness than appreciation for what one has- both physically and in the way of relationships and ideologies. The unhappy seek that which they do not have and can not fully appreciate the things around them. I don’t expect much from life. I don’t need a high paying job, a big house or fancy cars. I simply wish to be able to live my life appreciating everything around me.
25+
')
4326
44-
### scrape.striplinks <- function(text)
45-
Strips all links of the form `http*` found in text. Useful for normalizing sentimetn scores
27+
# 1. Simple Summation
28+
out <- classify.aggregate(test, positive, negative)
29+
out
4630
47-
## Plotting Utilities
31+
# 2. Naive Bayes
32+
out <- classify.naivebayes(test)
33+
out
34+
```
4835

49-
### multiplot <- function(..., plotlist=NULL, cols)
50-
Allows for multiple `ggplot` instances to be printed together.
36+
Output:
37+
```
38+
score
39+
1 1
40+
2 -1
41+
3 2
42+
43+
POS NEG POS/NEG SENT
44+
[1,] "9.47547003995745" "0.445453222112551" "21.2715265477714" "positive"
45+
[2,] "1.03127774142571" "9.47547003995745" "0.108836578774127" "negative"
46+
[3,] "67.1985217685598" "35.1792261323723" "1.9101762362738" "positive"
47+
```

0 commit comments

Comments
 (0)