PHP Classes

i have an error to running this code

Recommend this page to a friend!

      PHP Sentiment Analyzer  >  All threads  >  i have an error to running this code  >  (Un) Subscribe thread alerts  
Subject:i have an error to running this code
Summary:error displays in SentimentAnalyzer.class.php
Messages:4
Author:Vasim Seta
Date:2015-07-24 01:22:48
 

  1. i have an error to running this code   Reply   Report abuse  
Picture of Vasim Seta Vasim Seta - 2015-07-24 01:22:49
hi! i have download your sentiment-analyzer-2015-07-04.zip file and than i was try to test it. when i run test.php file it shows me an error "Parse error: syntax error, unexpected '[' in D:\xampp\htdocs\sent\src\SentimentAnalyzer.class.php on line 86", can you tell me what the problem is in this code? can you resolve it?

  2. Re: i have an error to running this code   Reply   Report abuse  
Picture of Samuel Adeshina Samuel Adeshina - 2015-08-22 22:10:39 - In reply to message 1 from Vasim Seta
Hi, sorry it took so long to reply. The error you are getting is due to the fact that an invalid training data location was supplied. Maybe you need to check the example scripts again and change the location of the test file to a valid one relative to your working directory?

I don't know how your working directory is structured but from the error message you are getting, I think the test data location should look something like this:

D:\xampp\htdocs\sent\trainingSet\data.neg

Try that, it should work. But feel free to post here, if you still face any difficulty. Thanks

  3. Re: i have an error to running this code   Reply   Report abuse  
Picture of E. Hackenitz E. Hackenitz - 2015-09-01 07:36:45 - In reply to message 1 from Vasim Seta
Getting the same errors....my trainingset location looks fine so perhaps there is another problem or the documentation is insufficient.

  4. Re: i have an error to running this code   Reply   Report abuse  
Picture of Zack Schreiber Zack Schreiber - 2015-09-01 15:29:00 - In reply to message 2 from Samuel Adeshina
i fixed this error by breaking the row with the error into two rows to get the array brackes off the function itself.

86: $words1 = self::splitSentence($testDatum);
87: $words = $words1[0];

There's also a place to do this in the analyzeSentence function
$words1 = self::splitSentence($sentence);
$words = $words1[0];

There are also a lot of places that gave me div by zero errors when calculating $bayesDifference