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
Copy file name to clipboardExpand all lines: README.md
+51-26
Original file line number
Diff line number
Diff line change
@@ -6,33 +6,39 @@
6
6
7
7
A simple wrapper for the [PHP-NLP-Client](https://github.com/web64/php-nlp-client) library for accessing Python and Java NLP libraries and external NLP APIs.
Plese follow the instructions here to install the NLP Server and CoreNLP server:
19
-
*https://github.com/web64/nlpserver
20
-
*https://github.com/web64/php-nlp-client
21
16
22
-
If you want to use Opencalais, get a token by registering [here](http://www.opencalais.com/) and read their [terms of service](http://www.opencalais.com/open-calais-terms-of-service/)
17
+
-https://github.com/web64/nlpserver
18
+
-https://github.com/web64/php-nlp-client
19
+
20
+
If you want to use Opencalais, get a token by registering [here](http://www.opencalais.com/) and read their [terms of service](http://www.opencalais.com/open-calais-terms-of-service/)
23
21
24
22
## Configuration
23
+
25
24
Add `NLPSERVER_URL` to your `.env` file to specify the location of where the NLP Server is running.
26
25
If you want to use [CoreNLP](https://stanfordnlp.github.io/CoreNLP/download.html) or [Opencalais](http://www.opencalais.com/) also fill inn those details in .env.
27
26
28
-
Alternatively, update the nlp.php configuration file.
29
27
```
30
28
NLPSERVER_URL="http://localhost:6400/"
31
29
CORENLP_HOST="http://localhost:9000/"
32
30
OPENCALAIS_KEY=
33
31
```
34
32
33
+
Alternatively, update the nlp.php configuration file.
This function uses the [Polyglot](https://polyglot.readthedocs.io/en/latest/Installation.html) library which supports entity extraction for 40 languages.
102
115
Make sure you have downloaded the language models for the languages you are using.
103
116
104
117
For English and other major European languages use [Spacy](https://spacy.io/usage/) or [CoreNLP](https://stanfordnlp.github.io/CoreNLP/download.html) for best results.
118
+
105
119
```php
106
120
$text = "Barack Hussein Obama is an American politician who served as the 44th President of the United States from January 20, 2009 to January 20, 2017. Before that, he served in the Illinois State Senate from 1997 until 2004.";
107
121
@@ -118,9 +132,11 @@ Array
118
132
```
119
133
120
134
## Entity Extraction with Spacy
135
+
121
136
A running NLP Server provides access to Spacy's entity extraction.
122
137
123
138
Spacy has language models for English, German, Spanish, Portuguese, French, Italian and Dutch.
139
+
124
140
```php
125
141
$entities = NLP::spacy_entities($text, 'en' );
126
142
/*
@@ -145,6 +161,7 @@ array:4 [
145
161
```
146
162
147
163
### Entitiy extraction with CoreNLP
164
+
148
165
[CoreNLP](https://github.com/web64/php-nlp-client#corenlp---entity-extraction-ner) provides very good entoty extraction for English texts.
149
166
150
167
To use this function you need a running instance of the CoreNLP server. [See installation inststructions](https://github.com/web64/php-nlp-client#corenlp---entity-extraction-ner)
@@ -179,8 +196,8 @@ array:6 [
179
196
```
180
197
181
198
### Sentiment Analysis
182
-
This will return a value ranging from -1 to +1, where > 0 is considered to have a positive sentiment and everython < 0 has a negative sentiment.
183
199
200
+
This will return a value ranging from -1 to +1, where > 0 is considered to have a positive sentiment and everython < 0 has a negative sentiment.
184
201
185
202
Provide the language code as the second parameter to specify the language of the text. (default='en').
0 commit comments