Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

positive and negative columns names are not returned when there are no positive and negative when using extract_sentiment_terms functions #41

Closed
sivaram10 opened this issue May 24, 2017 · 4 comments

Comments

@sivaram10
Copy link

when using extract_sentiment_terms in the context of a data.table, extract_sentiment_terms is not returning positive and neutral columns which is causing extract_sentiment_terms function fail on records below it.

datatable[, Positive.Terms :=
extract_sentiment_terms(Comment)[,positive], by = "Comment"]

Error in [.data.table(extract_sentiment_terms("Attach files by dropping, Choose Files selecting them from the clipboard."), :
Variable 'positive' is not found in calling scope. Looking in calling scope because either you used the .. prefix or set with=FALSE

This above issue is causing the records below the failed records also fail.
Is there any better way to use this function in context of data.table to over come this problem.

@trinker
Copy link
Owner

trinker commented May 25, 2017

Can you provide a minimal working example?

@sivaram10
Copy link
Author

When there are no positive or negative words in the text, extract_sentiment_terms is not returning positive and negative lists.

extract_sentiment_terms("Data analysis, also known as analysis of data or data analytics, is a process of inspecting and modeling data with the goal of suggesting conclusions, and decision-making.")
image

extract_sentiment_terms("Data analysis, also known as analysis of data or data analytics, is a process of inspecting, cleansing, transforming, and modeling data with the goal of discovering useful information, suggesting conclusions, and supporting decision-making.")
image

If I use this along with data table, data table is throwing error as it was not able to find positive named list.
Is there any way you can update the code so that extract_sentiment_terms gives empty list of positive/negative terms when there are no positive/negative terms in the text.

@trinker
Copy link
Owner

trinker commented Jun 5, 2017

I'm not seeing how you're using this with data.table? Can you show the use case?

@sivaram10
Copy link
Author

dt <- data.table(comments = c("She is a good girl and I like her.", "He is arrogant."))
dt[, positive.terms := extract_sentiment_terms(comments)[,positive], by = "comments"]

Error in [.data.table(extract_sentiment_terms(comments), , positive) :
j (the 2nd argument inside [...]) is a single symbol but column name 'positive' is not found. Perhaps you intended DT[,..positive] or DT[,positive,with=FALSE]. This difference to data.frame is deliberate and explained in FAQ 1.1.
In addition: Warning message:
In [.data.table(dt, , :=(positive.terms, extract_sentiment_terms(comments)[, :
RHS 1 is length 2 (greater than the size (1) of group 1). The last 1 element(s) will be discarded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants