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
Most NLP features in this package requires a running instance of the NLP-Server, which is a simple python flask app providing web service api access to common python NLP libraries.
This uses the Polyglot multilingual NLP library to return entities and a sentiment score for given text.Ensure the models for the required languages are downloaded for Polyglot.
85
+
80
86
```php
81
-
$nlp = new \Web64\Nlp\NlpClient('http://localhost:6400/');
$nlp = new \Web64\Nlp\NlpClient('http://localhost:6400/');
91
-
$neighbours = $nlp->neighbours('obama', 'en');
91
+
$polyglot->getEntityTypes();
92
92
/*
93
93
Array
94
94
(
95
-
[0] => Bush
96
-
[1] => Reagan
97
-
[2] => Clinton
98
-
[3] => Ahmadinejad
99
-
[4] => Nixon
100
-
[5] => Karzai
101
-
[6] => McCain
102
-
[7] => Biden
103
-
[8] => Huckabee
104
-
[9] => Lula
95
+
[Locations] => Array
96
+
(
97
+
[0] => United Kingdom
98
+
)
99
+
[Organizations] =>
100
+
[Persons] => Array
101
+
(
102
+
[0] => Ben
103
+
[1] => Sir Benjamin Hall
104
+
[2] => Benjamin Caunt
105
+
)
106
+
)
107
+
*/
108
+
109
+
$polyglot->getLocations(); // Array of Locations
110
+
$polyglot->getOrganizations(); // Array of organisations
111
+
$polyglot->getPersons(); // Array of people
112
+
113
+
$polyglot->getEntities();
114
+
/*
115
+
Returns combined array of all entities
116
+
Array
117
+
(
118
+
[0] => Ben
119
+
[1] => United Kingdom
120
+
[2] => Sir Benjamin Hall
121
+
[3] => Benjamin Caunt
105
122
)
106
123
*/
107
124
```
108
125
126
+
127
+
109
128
### Spacy Entities
110
129
```php
111
130
$text = "Harvesters is a 1905 oil painting on canvas by the Danish artist Anna Ancher, a member of the artists' community known as the Skagen Painters.";
@@ -143,6 +162,26 @@ English is used by default. To use another language ensure Spacy language model
0 commit comments