OPAL: Opinion Analyzer

OPAL is a Drupal plugin that analyses comments posted by users and detects whether they are positive, negative or neutral. In addition, it calculates the joint polarity of all comments attached to a content type and deliveries an overall rank for the post.

The goal of the application is to show how opinion mining can aid in assessment of content such as ideas in Idea Management Systems.

By default OPAL will add snippets to all content types and comments.
For content types it will display:

  • An image that visualises balance between emotions expressed in all comments
  • Overall polarity score together with percentage of positive/negative/neutral posts
  • Amount of positive, negative and neutral posts

For each comment:

  • An image that visualises the sentiments in the comment (positive, negative or neutral)
  • Polarity score

In each case the amount of information that is shown can be customized in module settings (Site Configuration/Opinion Analyser). All the information can be themed with CSS (see module directory) but is also passed in $node and $comment objects for more advanced theming. In addition, OPAL is supported by RDFme so its possible to export the opinion mining data along with other information into RDF/XML.

Images:
Screenshot
Snippets

Demo Website:
OPAL at www.fernandotapiarico.com

Project Sandbox: http://drupal.org/sandbox/FernandoTapiaRico/1085144

CommentFileSizeAuthor
#11 opal-greatsuccess.png60.73 KBcoderintherye

Comments

heine’s picture

Status: Active » Needs review

If did a partial review and posted some critical issues on the sandbox issue queue.

coderintherye’s picture

Status: Needs review » Needs work

Based on the issues that Heine filed I think this is currently a "needs work". Looking forward to seeing it move forward though, got my eye on this one.

FernandoTapiaRico’s picture

Status: Needs work » Needs review

Fixed the issues
Thanks guys for the reviews

rfay’s picture

Component: new project application » module
Status: Needs review » Needs work

How can your opal.info not have a core = 6.x or core = 7.x in it?

We don't use $Id$ any more, so you can remove those.

What is the source and license of the sentiwordnet database?

Could you just use variable_set() instead of having an opal_config database?

Overall, it looks like this one is pretty close. Thanks for playing, and sorry for the long wait between reviews.

BTW: I see that your reponses to those three issues were all contained in a single commit. It would be better practice to use one commit per issue, so that someone could see what you did to fix their exact issue. (And as I said over there, quote the hash or a link to the commitlog so somebody could see what you actually did. Or include a patch.)

FernandoTapiaRico’s picture

Hi rfay,
I just added 'core= "6.x"' to opal.info. I also remove the $Id$ tags. The SentiWordNet license is free for non-commercial use (link). It was a good idea to use variable_set instead of opal_config database.
Here is my commit.

Thank you all for the reviews.

rfay’s picture

If SentiWordnet is not GPL it will have to be removed and you'll have to have instructions on how to load it.

http://drupal.org/licensing/faq

FernandoTapiaRico’s picture

Ok,
I updated the OPAL info and removed the SentiWordNet database from the sources. I don't really like this solution and I'm trying to create an external service or use APIs like this one.
Here is the link to the last commit.
I added the following lines to the module description:

Initial setup

Before installing the module, you must copy the SentiWordNet database in your OPAL directory. You can download it from: here

IMPORTANT: SentiWordnet License

FernandoTapiaRico’s picture

Status: Needs work » Needs review
coderintherye’s picture

Status: Needs review » Needs work

Admittedly, the hard position on keeping non-GPL content off of d.o. does make for difficulties sometimes, but I think you'll see it prevents a lot of problems and is worth it in the long run.

I'm still really excited about this, especially after this post on Hacker News today:

So a couple things:

1) Create a README.txt - This file should contain info on how to obtain and use the SentiWordnet database along with any other information that would make it easier for a user to install your module.
2) Use the coder module to perform code reviews http://drupal.org/project/coder - This will help you clean up your code to better meet d.o. standards
3) It seems like you are using SQL queries as your hammer to solve all problems. This isn't too bad in and of itself, but where possible see if there are places where a Drupal function is already in place to give you the data you need rather than
4) For your log file (line 630 or so), you shouldn't hardcode sites/default/files, but rather use the file handling functions - http://api.drupal.org/api/drupal/includes--file.inc/group/file/6
5) I'm concerned about the Google Translation API usage because it's being deprecated. Is there an alternative way to handle this functionality? (See http://code.google.com/apis/language/translate/overview.html )

Keep up the good work, it's getting there.

FernandoTapiaRico’s picture

Status: Needs work » Needs review

Hi nowarninglabel,
thanks for the tips. I just updated the module, here is the commit:
http://drupalcode.org/sandbox/FernandoTapiaRico/1085144.git/commit/f2d4ca2751c73238d62e6a6c2f90593a7dc8e984

1) Done
2) I used the latest version of Coder module. I only got this error:

Line -1: Include the CVS keyword $Id$ in each file. This should be in the format // $Id$ or // $Id$ (Drupal Docs)

But that's not valid after GIT adoption

3) I noticed that, but I didn't find any Drupal function to get a comment from its ID, or all the Drupal nodes. if you can give me some light on this, I would appreciate it.
4) I removed log file (used for development)
5) I change Google Translator API for Microsoft Translator API
Regards

coderintherye’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new60.73 KB

Ok, I just ran the updated version on a fresh D6 site and it's working great. I'm attaching a screenshot of how it analyzed a comment and node.

Honestly, this looks like a great success, at least worthy of a dev release so others can get involved. I'll offer to help co-maintain a bit if needed. I'm sure others who have a more detailed eye might pick up on some things, but you've responded timely with updates and look like you understand how to do everything a project maintainer should do so I'm +1 on giving you commit access and a project page.

FernandoTapiaRico’s picture

Hi nowarninglabel,
thanks for your support. Any help on the project would be appreciated, so feel free to "come on board". At this moment, it's more a proof of concept than a solid module, but that's the nice thing: there is a lot of stuff to improve.
Cheers

sreynen’s picture

Status: Reviewed & tested by the community » Needs work

Sorry, I don't think this is quite ready yet. I opened a few issues in your project queue. Please move this back to "needs review" when those are addressed.

FernandoTapiaRico’s picture

I'm currently on vacations. I will take a look to those issues when I come back. Thanks for debugging my app. Cheers

FernandoTapiaRico’s picture

Status: Needs work » Needs review

Hi sreynen,
sorry for the late reply, but I've been busy with my projects related to RDFLib and Apache Mahout. I've fixed all the issues that you pointed out:

Thanks for your time.
Best regards

sreynen’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work

Please read through CSS Cleanup, there are a lot of functional styles mixed in with arbitrary coloring.

Also, the definition for hook_init() says "To add CSS or JS that should be present on all pages, modules should not implement this hook, but declare these files in their .info file."

When writing CSS, 0 (zero) is unitless. Therefore, left: 0px; should be left: 0;.

In the .info file, there are no quotes around any of the values, and you are missing the description.

Remember to not end lines with extra whitespace.

Finally, remove the author and version information from each file.

FernandoTapiaRico’s picture

Hi Tim,
thanks for your help, it's always good to learn things. I fixed everything except the hook_init() thing. This is a Drupal 6.x module, not a 7.x module (or, at least, I didn't check if it works on the new version of Drupal). So, I'm following this:
hook_init() [Drupal 6]
instead of this:
hook_init() [Drupal 7]

In case of I submit a Drupal 7.x version, I will add to opal.info these lines:

stylesheets[all][] = css/opal.base.css
stylesheets[all][] = css/opal.theme.css

and remove these ones:

/**
 * Implements hook_init().
 */
function opal_init() {
  drupal_add_css(drupal_get_path('module', 'opal') .'/css/opal.base.css');
  drupal_add_css(drupal_get_path('module', 'opal') .'/css/opal.theme.css');
}

Here are the commits:
Issues: http://drupalcode.org/sandbox/FernandoTapiaRico/1085144.git/commit/f82675d
Some CSS refactoring: http://drupalcode.org/sandbox/FernandoTapiaRico/1085144.git/commit/8b11e3a
Cheers

FernandoTapiaRico’s picture

Status: Needs work » Needs review
tim.plunkett’s picture

Status: Needs review » Fixed

You are completely right, that is a D7-only feature (see #328357: Allow module .info files to add CSS/JS). Thanks for pointing that out and not just blindly following my suggestions!

I've granted you full project creation rights. Use this ability carefully!

Thank you for your patience.

coderintherye’s picture

Well done, welcome to the community. Look forward to seeing more of your work.

FernandoTapiaRico’s picture

Thank you nowarninglabel
I will do my best.
Best regards

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.