You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Aproko doctor made me 🤣 ------------- ['neg' => 0, 'neu' => 1, 'pos' => 0, 'compound' => 0]
62
+
Aproko doctor made me 🤣 ------------- ['neg' => 0, 'neu' => 0.714, 'pos' => 0.286, 'compound' => 0.4939]
63
63
64
64
```
65
65
66
+
67
+
68
+
### Advance Usage
69
+
70
+
You can now dynamically update the VADER (Valence) lexicon on the fly for words that are not in the dictionary. See Example below:
71
+
72
+
73
+
```php
74
+
75
+
76
+
Use Sentiment\Analyzer;
77
+
78
+
$sentiment = new Sentiment\Analyzer();
79
+
80
+
$strings = [
81
+
'Weather today is rubbish',
82
+
'This cake looks amazing',
83
+
'His skills are mediocre',
84
+
'He is very talented',
85
+
'She is seemingly very agressive',
86
+
'Marie was enthusiastic about the upcoming trip. Her brother was also passionate about her leaving - he would finally have the house for himself.',
87
+
'To be or not to be?',
88
+
];
89
+
90
+
//new words not in the dictionary
91
+
$newWords = [
92
+
'rubbish'=> '-1.5',
93
+
'mediocre' => '-1.0',
94
+
'agressive' => '-0.5'
95
+
];
96
+
97
+
//Dynamically update the dictionary with the new words
98
+
$sentiment->updateLexicon($newWords);
99
+
100
+
//Print results
101
+
foreach ($strings as $string) {
102
+
// calculations:
103
+
$scores = $sentiment->getSentiment($string);
104
+
// output:
105
+
echo "String: $string\n";
106
+
print_r(json_encode($scores));
107
+
echo "<br>";
108
+
}
109
+
110
+
111
+
```
112
+
113
+
114
+
### Advance Outputs
115
+
116
+
117
+
```
118
+
119
+
Weather today is rubbish ------------- {"neg":0.455,"neu":0.545,"pos":0,"compound":-0.3612}
120
+
121
+
This cake looks amazing ------------- {"neg":0,"neu":0.441,"pos":0.559,"compound":0.5859}
122
+
123
+
His skills are mediocre ------------- {"neg":0.4,"neu":0.6,"pos":0,"compound":-0.25}
124
+
125
+
He is very talented ------------- {"neg":0,"neu":0.457,"pos":0.543,"compound":0.552}
126
+
127
+
She is seemingly very agressive ------------- {"neg":0.338,"neu":0.662,"pos":0,"compound":-0.2598}
128
+
129
+
Marie was enthusiastic about the upcoming trip. Her brother was also passionate about her leaving - he would finally have the house for himself. ------------- {"neg":0,"neu":0.761,"pos":0.239,"compound":0.765}
130
+
131
+
String: To be or not to be? ------------- {"neg":0,"neu":1,"pos":0,"compound":0}
132
+
133
+
```
134
+
135
+
66
136
### License
67
137
68
138
This package is licensed under the [MIT license](https://github.com/davmixcool/php-sentiment-analyzer/blob/master/LICENSE).
0 commit comments