0

I'm trying to see the source of the analyzeSentiment()function for the SentimentAnalysispackage. First I use ::::

> SentimentAnalysis:::analyzeSentiment
function (x, language = "english", aggregate = NULL, rules = 
defaultSentimentRules(), 
    removeStopwords = TRUE, stemming = TRUE, ...) 
{
    UseMethod("analyzeSentiment", x)
}

Using methods() I see that the function behaves according to the class of the input

> methods(analyzeSentiment)
[1] analyzeSentiment.character*          analyzeSentiment.Corpus*            
[3] analyzeSentiment.data.frame*        analyzeSentiment.DocumentTermMatrix*
[5] analyzeSentiment.TermDocumentMatrix*

When I try to look into these functions using ::: they all rely on a function called analyzeSentiment.

> SentimentAnalysis:::analyzeSentiment.TermDocumentMatrix
function (x, language = "english", aggregate = NULL, rules = 
defaultSentimentRules(), 
    removeStopwords = TRUE, stemming = TRUE, ...) 
{
    analyzeSentiment(t(x), language, aggregate, rules, removeStopwords, 
        stemming, ...)
}

This is the very function I started out by looking into and which got me here. I'm curious as to how it's written. Please help me out of this vicious circle!

WiggyStardust
  • 182
  • 1
  • 10
  • Try `getAnywhere(function_you_want)` – Rui Barradas Jul 28 '18 at 16:48
  • 1
    Have a look in [github](https://github.com/cran/SentimentAnalysis/blob/master/R/analyzeSentiment.R) – IanRiley Jul 28 '18 at 17:32
  • Tried `getAnywhere` but it's equivalent to `:::`. Ah thanks for the github tip! – WiggyStardust Jul 28 '18 at 17:37
  • 1
    Notice that function calls `analyzeSentiment(t(x),...)` and the transpose of a TermDocumentMatrix is a DocumentTermMatrix so the code is in `SentimentAnalysis:::analyzeSentiment.DocumentTermMatrix` which does not call `analyzeSentiment` again. So they didn't **all** rely on that function. – MrFlick Jul 28 '18 at 19:40

0 Answers0