-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit Tests for custom dictionaries/data sources.
- Loading branch information
1 parent
797ba6c
commit 362adb5
Showing
7 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
tests/LaravelSentimentAnalysis/SentimentAnalysisReversedTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
use Antoineaugusti\LaravelSentimentAnalysis\SentimentAnalysis; | ||
|
||
class SentimentAnalysisReversedTest extends PHPUnit_Framework_TestCase { | ||
|
||
public $sentiment; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
/** | ||
* The positive and negative data has been reversed. | ||
* Neutral/Positive/Ignore are the same. | ||
*/ | ||
$this->sentiment = new SentimentAnalysis(__DIR__.'/reversed/'); | ||
} | ||
|
||
public function testIsPositive() | ||
{ | ||
$this->assertEquals(false, $this->sentiment->isPositive('Marie was enthusiastic')); | ||
$this->assertEquals(false, $this->sentiment->isPositive('He is very talented')); | ||
} | ||
|
||
public function testIsNeutral() | ||
{ | ||
$this->assertEquals(true, $this->sentiment->isNeutral('His views are not considerable')); | ||
$this->assertEquals(true, $this->sentiment->isNeutral('She is seemingly very surprising')); | ||
} | ||
|
||
public function testIsNegative() | ||
{ | ||
$this->assertEquals(false, $this->sentiment->isNegative('Weather today is rubbish')); | ||
} | ||
|
||
public function testDecision() | ||
{ | ||
// Positive | ||
$this->assertEquals('negative', $this->sentiment->decision('Marie was enthusiastic about the upcoming trip. Her brother was also passionate about her leaving - he would finally have the house for himself.')); | ||
$this->assertEquals('negative', $this->sentiment->decision('He is really very talented')); | ||
|
||
// Neutral | ||
$this->assertEquals('neutral', $this->sentiment->decision('His views are not reflecting')); | ||
$this->assertEquals('neutral', $this->sentiment->decision('She is seemingly very surprising')); | ||
|
||
// Negative | ||
$this->assertEquals('positive', $this->sentiment->decision('Weather today is very rubbish')); | ||
} | ||
|
||
public function testScores() | ||
{ | ||
$this->assertEquals(['negative' => 0.25, 'neutral' => 0.25, 'positive' => 0.5], $this->sentiment->scores('Weather today is very rubbish')); | ||
$this->assertEquals(['negative' => 0.33, 'neutral' => 0.33, 'positive' => 0.33], $this->sentiment->scores('To be or not to be?')); | ||
} | ||
|
||
public function testScore() | ||
{ | ||
$this->assertEquals(0.5, $this->sentiment->score('Weather today is very rubbish')); | ||
$this->assertEquals(0.33, $this->sentiment->score('To be or not to be?')); | ||
$this->assertEquals(0.57, $this->sentiment->score('Marie was enthusiastic about the upcoming trip. Her brother was also passionate about her leaving - he would finally have the house for himself.')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a:578:{i:0;s:6:"ccedil";i:1;s:5:"aelig";i:2;s:4:"much";i:3;s:6:"mostly";i:4;s:4:"most";i:5;s:8:"moreover";i:6;s:4:"more";i:7;s:5:"might";i:8;s:6:"merely";i:9;s:9:"meanwhile";i:10;s:4:"mean";i:11;s:2:"me";i:12;s:5:"maybe";i:13;s:3:"may";i:14;s:4:"many";i:15;s:6:"mainly";i:16;s:3:"ltd";i:17;s:5:"looks";i:18;s:7:"looking";i:19;s:4:"look";i:20;s:6:"little";i:21;s:6:"likely";i:22;s:5:"liked";i:23;s:5:"let's";i:24;s:3:"let";i:25;s:4:"lest";i:26;s:4:"less";i:27;s:5:"least";i:28;s:8:"latterly";i:29;s:6:"latter";i:30;s:5:"later";i:31;s:6:"lately";i:32;s:4:"last";i:33;s:5:"knows";i:34;s:5:"known";i:35;s:4:"know";i:36;s:4:"kept";i:37;s:5:"keeps";i:38;s:4:"keep";i:39;s:4:"just";i:40;s:6:"itself";i:41;s:3:"its";i:42;s:4:"it's";i:43;s:5:"it'll";i:44;s:4:"it'd";i:45;s:2:"it";i:46;s:2:"is";i:47;s:6:"inward";i:48;s:4:"into";i:49;s:7:"instead";i:50;s:7:"insofar";i:51;s:5:"inner";i:52;s:9:"indicates";i:53;s:9:"indicated";i:54;s:8:"indicate";i:55;s:6:"indeed";i:56;s:3:"inc";i:57;s:8:"inasmuch";i:58;s:2:"in";i:59;s:9:"immediate";i:60;s:7:"ignored";i:61;s:2:"if";i:62;s:2:"ie";i:63;s:4:"i've";i:64;s:3:"i'm";i:65;s:4:"i'll";i:66;s:3:"i'd";i:67;s:7:"however";i:68;s:7:"howbeit";i:69;s:3:"how";i:70;s:9:"hopefully";i:71;s:6:"hither";i:72;s:3:"his";i:73;s:7:"himself";i:74;s:3:"him";i:75;s:2:"hi";i:76;s:7:"herself";i:77;s:4:"hers";i:78;s:8:"hereupon";i:79;s:6:"herein";i:80;s:6:"hereby";i:81;s:9:"hereafter";i:82;s:6:"here's";i:83;s:4:"here";i:84;s:3:"her";i:85;s:5:"hence";i:86;s:4:"help";i:87;s:5:"hello";i:88;s:4:"he's";i:89;s:2:"he";i:90;s:6:"having";i:91;s:7:"haven't";i:92;s:4:"have";i:93;s:6:"hasn't";i:94;s:3:"has";i:95;s:6:"hardly";i:96;s:7:"happens";i:97;s:6:"hadn't";i:98;s:3:"had";i:99;s:9:"greetings";i:100;s:6:"gotten";i:101;s:3:"got";i:102;s:4:"gone";i:103;s:5:"going";i:104;s:4:"goes";i:105;s:2:"go";i:106;s:5:"gives";i:107;s:5:"given";i:108;s:7:"getting";i:109;s:4:"gets";i:110;s:3:"get";i:111;s:11:"furthermore";i:112;s:7:"further";i:113;s:4:"from";i:114;s:4:"four";i:115;s:5:"forth";i:116;s:8:"formerly";i:117;s:6:"former";i:118;s:3:"for";i:119;s:7:"follows";i:120;s:9:"following";i:121;s:8:"followed";i:122;s:4:"five";i:123;s:5:"first";i:124;s:5:"fifth";i:125;s:3:"few";i:126;s:3:"far";i:127;s:6:"except";i:128;s:7:"example";i:129;s:7:"exactly";i:130;s:2:"ex";i:131;s:10:"everywhere";i:132;s:10:"everything";i:133;s:8:"everyone";i:134;s:9:"everybody";i:135;s:5:"every";i:136;s:4:"ever";i:137;s:4:"even";i:138;s:3:"etc";i:139;s:2:"et";i:140;s:10:"especially";i:141;s:8:"entirely";i:142;s:6:"enough";i:143;s:9:"elsewhere";i:144;s:4:"else";i:145;s:6:"either";i:146;s:5:"eight";i:147;s:2:"eg";i:148;s:3:"edu";i:149;s:4:"each";i:150;s:6:"during";i:151;s:9:"downwards";i:152;s:4:"down";i:153;s:4:"done";i:154;s:5:"don't";i:155;s:5:"doing";i:156;s:7:"doesn't";i:157;s:4:"does";i:158;s:2:"do";i:159;s:9:"different";i:160;s:6:"didn't";i:161;s:3:"did";i:162;s:7:"despite";i:163;s:9:"described";i:164;s:10:"definitely";i:165;s:9:"currently";i:166;s:6:"course";i:167;s:8:"couldn't";i:168;s:5:"could";i:169;s:13:"corresponding";i:170;s:8:"contains";i:171;s:10:"containing";i:172;s:7:"contain";i:173;s:11:"considering";i:174;s:8:"consider";i:175;s:12:"consequently";i:176;s:10:"concerning";i:177;s:5:"comes";i:178;s:4:"come";i:179;s:3:"com";i:180;s:2:"co";i:181;s:7:"clearly";i:182;s:7:"changes";i:183;s:9:"certainly";i:184;s:7:"certain";i:185;s:6:"causes";i:186;s:5:"cause";i:187;s:4:"cant";i:188;s:6:"cannot";i:189;s:5:"can't";i:190;s:3:"can";i:191;s:4:"came";i:192;s:3:"c's";i:193;s:5:"c'mon";i:194;s:2:"by";i:195;s:3:"but";i:196;s:5:"brief";i:197;s:4:"both";i:198;s:6:"beyond";i:199;s:7:"between";i:200;s:6:"better";i:201;s:4:"best";i:202;s:7:"besides";i:203;s:6:"beside";i:204;s:5:"below";i:205;s:7:"believe";i:206;s:5:"being";i:207;s:6:"behind";i:208;s:10:"beforehand";i:209;s:6:"before";i:210;s:4:"been";i:211;s:8:"becoming";i:212;s:7:"becomes";i:213;s:6:"become";i:214;s:7:"because";i:215;s:6:"became";i:216;s:2:"be";i:217;s:7:"awfully";i:218;s:4:"away";i:219;s:9:"available";i:220;s:2:"at";i:221;s:10:"associated";i:222;s:6:"asking";i:223;s:3:"ask";i:224;s:5:"aside";i:225;s:2:"as";i:226;s:6:"around";i:227;s:3:"are";i:228;s:11:"appropriate";i:229;s:10:"appreciate";i:230;s:6:"appear";i:231;s:5:"apart";i:232;s:8:"anywhere";i:233;s:7:"anyways";i:234;s:6:"anyway";i:235;s:8:"anything";i:236;s:6:"anyone";i:237;s:6:"anyhow";i:238;s:7:"anybody";i:239;s:3:"any";i:240;s:7:"another";i:241;s:3:"and";i:242;s:2:"an";i:243;s:7:"amongst";i:244;s:5:"among";i:245;s:2:"am";i:246;s:6:"always";i:247;s:8:"although";i:248;s:4:"also";i:249;s:7:"already";i:250;s:5:"along";i:251;s:5:"alone";i:252;s:6:"almost";i:253;s:6:"allows";i:254;s:5:"allow";i:255;s:3:"all";i:256;s:7:"against";i:257;s:5:"again";i:258;s:10:"afterwards";i:259;s:5:"after";i:260;s:8:"actually";i:261;s:6:"across";i:262;s:11:"accordingly";i:263;s:9:"according";i:264;s:5:"above";i:265;s:5:"about";i:266;s:4:"able";i:267;s:5:"ain't";i:268;s:3:"bit";i:269;s:4:"para";i:270;s:5:"cedil";i:271;s:5:"https";i:272;s:5:"zynga";i:273;s:4:"must";i:274;s:2:"my";i:275;s:6:"myself";i:276;s:4:"name";i:277;s:6:"namely";i:278;s:2:"nd";i:279;s:4:"near";i:280;s:6:"nearly";i:281;s:9:"necessary";i:282;s:4:"need";i:283;s:5:"needs";i:284;s:7:"neither";i:285;s:5:"never";i:286;s:12:"nevertheless";i:287;s:3:"new";i:288;s:4:"next";i:289;s:4:"nine";i:290;s:2:"no";i:291;s:6:"nobody";i:292;s:3:"non";i:293;s:4:"none";i:294;s:5:"noone";i:295;s:3:"nor";i:296;s:8:"normally";i:297;s:7:"nothing";i:298;s:5:"novel";i:299;s:3:"now";i:300;s:7:"nowhere";i:301;s:9:"obviously";i:302;s:2:"of";i:303;s:3:"off";i:304;s:5:"often";i:305;s:2:"oh";i:306;s:2:"ok";i:307;s:4:"okay";i:308;s:3:"old";i:309;s:2:"on";i:310;s:4:"once";i:311;s:3:"one";i:312;s:4:"ones";i:313;s:4:"only";i:314;s:4:"onto";i:315;s:2:"or";i:316;s:5:"other";i:317;s:6:"others";i:318;s:9:"otherwise";i:319;s:5:"ought";i:320;s:3:"our";i:321;s:4:"ours";i:322;s:9:"ourselves";i:323;s:3:"out";i:324;s:7:"outside";i:325;s:4:"over";i:326;s:7:"overall";i:327;s:3:"own";i:328;s:10:"particular";i:329;s:12:"particularly";i:330;s:3:"per";i:331;s:7:"perhaps";i:332;s:6:"placed";i:333;s:6:"please";i:334;s:4:"plus";i:335;s:8:"possible";i:336;s:10:"presumably";i:337;s:8:"probably";i:338;s:8:"provides";i:339;s:3:"que";i:340;s:5:"quite";i:341;s:2:"qv";i:342;s:6:"rather";i:343;s:2:"rd";i:344;s:2:"re";i:345;s:6:"really";i:346;s:9:"regarding";i:347;s:10:"regardless";i:348;s:7:"regards";i:349;s:10:"relatively";i:350;s:12:"respectively";i:351;s:5:"right";i:352;s:4:"said";i:353;s:4:"same";i:354;s:3:"saw";i:355;s:3:"say";i:356;s:6:"saying";i:357;s:4:"says";i:358;s:6:"second";i:359;s:8:"secondly";i:360;s:3:"see";i:361;s:6:"seeing";i:362;s:4:"seem";i:363;s:6:"seemed";i:364;s:7:"seeming";i:365;s:5:"seems";i:366;s:4:"seen";i:367;s:4:"self";i:368;s:6:"selves";i:369;s:8:"sensible";i:370;s:4:"sent";i:371;s:7:"serious";i:372;s:9:"seriously";i:373;s:5:"seven";i:374;s:7:"several";i:375;s:5:"shall";i:376;s:3:"she";i:377;s:6:"should";i:378;s:9:"shouldn't";i:379;s:5:"since";i:380;s:3:"six";i:381;s:2:"so";i:382;s:4:"some";i:383;s:8:"somebody";i:384;s:7:"somehow";i:385;s:7:"someone";i:386;s:9:"something";i:387;s:8:"sometime";i:388;s:9:"sometimes";i:389;s:8:"somewhat";i:390;s:9:"somewhere";i:391;s:4:"soon";i:392;s:5:"sorry";i:393;s:9:"specified";i:394;s:7:"specify";i:395;s:10:"specifying";i:396;s:5:"still";i:397;s:3:"sub";i:398;s:4:"such";i:399;s:3:"sup";i:400;s:4:"sure";i:401;s:4:"take";i:402;s:5:"taken";i:403;s:4:"tell";i:404;s:5:"tends";i:405;s:2:"th";i:406;s:4:"than";i:407;s:5:"thank";i:408;s:6:"thanks";i:409;s:5:"thanx";i:410;s:4:"that";i:411;s:6:"that's";i:412;s:5:"thats";i:413;s:3:"the";i:414;s:5:"their";i:415;s:6:"theirs";i:416;s:4:"them";i:417;s:10:"themselves";i:418;s:4:"then";i:419;s:6:"thence";i:420;s:5:"there";i:421;s:7:"there's";i:422;s:10:"thereafter";i:423;s:7:"thereby";i:424;s:9:"therefore";i:425;s:7:"therein";i:426;s:6:"theres";i:427;s:9:"thereupon";i:428;s:5:"these";i:429;s:4:"they";i:430;s:6:"they'd";i:431;s:7:"they'll";i:432;s:7:"they're";i:433;s:7:"they've";i:434;s:5:"think";i:435;s:5:"third";i:436;s:4:"this";i:437;s:8:"thorough";i:438;s:10:"thoroughly";i:439;s:5:"those";i:440;s:6:"though";i:441;s:5:"three";i:442;s:7:"through";i:443;s:10:"throughout";i:444;s:4:"thru";i:445;s:4:"thus";i:446;s:2:"to";i:447;s:8:"together";i:448;s:3:"too";i:449;s:4:"took";i:450;s:6:"toward";i:451;s:7:"towards";i:452;s:5:"tried";i:453;s:5:"tries";i:454;s:5:"truly";i:455;s:3:"try";i:456;s:6:"trying";i:457;s:5:"twice";i:458;s:3:"two";i:459;s:2:"un";i:460;s:5:"under";i:461;s:13:"unfortunately";i:462;s:6:"unless";i:463;s:8:"unlikely";i:464;s:5:"until";i:465;s:4:"unto";i:466;s:2:"up";i:467;s:4:"upon";i:468;s:2:"us";i:469;s:3:"use";i:470;s:4:"used";i:471;s:4:"uses";i:472;s:5:"using";i:473;s:7:"usually";i:474;s:5:"value";i:475;s:7:"various";i:476;s:4:"very";i:477;s:3:"via";i:478;s:3:"viz";i:479;s:2:"vs";i:480;s:4:"want";i:481;s:5:"wants";i:482;s:3:"was";i:483;s:6:"wasn't";i:484;s:3:"way";i:485;s:2:"we";i:486;s:4:"we'd";i:487;s:5:"we'll";i:488;s:5:"we're";i:489;s:5:"we've";i:490;s:7:"welcome";i:491;s:4:"well";i:492;s:4:"went";i:493;s:4:"were";i:494;s:7:"weren't";i:495;s:4:"what";i:496;s:6:"what's";i:497;s:8:"whatever";i:498;s:4:"when";i:499;s:6:"whence";i:500;s:8:"whenever";i:501;s:5:"where";i:502;s:7:"where's";i:503;s:10:"whereafter";i:504;s:7:"whereas";i:505;s:7:"whereby";i:506;s:7:"wherein";i:507;s:9:"whereupon";i:508;s:8:"wherever";i:509;s:7:"whether";i:510;s:5:"which";i:511;s:5:"while";i:512;s:7:"whither";i:513;s:3:"who";i:514;s:5:"who's";i:515;s:7:"whoever";i:516;s:5:"whole";i:517;s:4:"whom";i:518;s:5:"whose";i:519;s:3:"why";i:520;s:4:"will";i:521;s:7:"willing";i:522;s:4:"wish";i:523;s:4:"with";i:524;s:6:"within";i:525;s:7:"without";i:526;s:5:"won't";i:527;s:6:"wonder";i:528;s:5:"would";i:529;s:8:"wouldn't";i:530;s:3:"yes";i:531;s:3:"yet";i:532;s:3:"you";i:533;s:5:"you'd";i:534;s:6:"you'll";i:535;s:6:"you're";i:536;s:6:"you've";i:537;s:4:"your";i:538;s:5:"yours";i:539;s:8:"yourself";i:540;s:10:"yourselves";i:541;s:4:"zero";i:542;s:6:"agrave";i:543;s:6:"atilde";i:544;s:4:"http";i:545;s:5:"acirc";i:546;s:5:"aring";i:547;s:4:"quot";i:548;s:6:"ntilde";i:549;s:3:"amp";i:550;s:4:"auml";i:551;s:4:"nbsp";i:552;s:5:"laquo";i:553;s:4:"iuml";i:554;s:6:"egrave";i:555;s:4:"macr";i:556;s:6:"brvbar";i:557;s:4:"ordm";i:558;s:6:"plusmn";i:559;s:3:"reg";i:560;s:3:"www";i:561;s:5:"acute";i:562;s:4:"cent";i:563;s:4:"ordf";i:564;s:6:"eacute";i:565;s:4:"frac";i:566;s:10:"sLZjpNxJtx";i:567;s:3:"ETH";i:568;s:5:"Icirc";i:569;s:4:"sect";i:570;s:3:"goo";i:571;s:3:"seu";i:572;s:4:"como";i:573;s:3:"ser";i:574;s:6:"filhos";i:575;s:4:"dlvr";i:576;s:5:"iexcl";i:577;s:6:"Ugrave";} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.