Skip to content

Commit 2f6dea5

Browse files
committed
docs(README.md): improving doc
1 parent 46b5e5b commit 2f6dea5

File tree

1 file changed

+43
-27
lines changed

1 file changed

+43
-27
lines changed

README.md

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,44 @@
22

33
*This project is under active development, please stay tuned for updates. More documentation and examples are comming.*
44

5+
This library connects to Stanford CoreNLP either via HTTP or by spawning processes. The first (HTTP) is the preferred method since it requires CoreNLP to initialize just once to serve many requests, it also avoids extra I/O given that the CLI method need to write temporary files to run.
56

67
## Setup
78

8-
This library connects to Stanford CoreNLP either via HTTP or by spawning processes. The first (HTTP) is the preferred method since it requires CoreNLP to initialize just once to serve many requests, it also avoids extra I/O given that the CLI method need to write temporary files to run.
9-
109
### 1. Install the package:
1110

12-
```
11+
```bash
1312
npm i --save corenlp
1413
```
1514

16-
### 2. Download CoreNLP
15+
### 2. Download Stanford CoreNLP
1716

18-
http://nlp.stanford.edu/software/stanford-corenlp-full-2017-06-09.zip
17+
Check the Stanford's project download section at: https://stanfordnlp.github.io/CoreNLP/download.html
18+
You may want to download, apart of the full package, other language models (see more on that page).
1919

20-
### 3.1. Use CoreNLP as HTTP Server
2120

22-
```
21+
### 3. Configure Stanford CoreNLP
22+
23+
#### 3.1. Use CoreNLP as HTTP Server
24+
25+
```bash
2326
# Run the server using all jars in the current directory (e.g., the CoreNLP home directory)
2427
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000
2528
```
2629

2730
CoreNLP connects by default via StanfordCoreNLPServer, using port 9000. You can also opt to setup the connection differently:
2831

29-
```
32+
```javascript
3033
import CoreNLP from 'corenlp';
3134

3235
CoreNLP.setup('English', new CoreNLP.connector.ConnectorServer({ dsn: 'http://localhost:9000' }));
3336
```
3437

35-
### 3.2. Use CoreNLP via CLI
38+
#### 3.2. Use CoreNLP via CLI
3639

3740
CoreNLP expects by default the StanfordCoreNLP package to be placed (unzipped) inside the path `${YOUR_NPM_PROJECT_ROOT}/corenlp/`. You can also opt to setup the CLI interface differently:
3841

39-
```
42+
```javascript
4043
import CoreNLP from 'corenlp';
4144

4245
CoreNLP.setup('English', new CoreNLP.connector.ConnectorCli({
@@ -47,16 +50,29 @@ CoreNLP.setup('English', new CoreNLP.connector.ConnectorCli({
4750
}));
4851
```
4952

53+
### 4. Use it
54+
55+
```javascript
56+
// ...
57+
58+
const sent = new CoreNLP.simple.Sentence('Hello world');
59+
sent.applyAnnotator(CoreNLP.simple.annotator.TokenizerAnnotator)
60+
.then(() => {
61+
console.log(sent.words());
62+
});
63+
```
64+
5065
## Examples
5166

52-
NOTE: The examples below assumes that StanfordCoreNLP is running on port `9000`.
67+
NOTE1: The examples below assumes that StanfordCoreNLP is running on port `9000`.
68+
NOTE2: The examples below assumes `es6` syntax, if you use require, use as follows: `var CoreNLP = require('corenlp').default;`
5369

5470
### English
5571

5672
```javascript
5773
import CoreNLP from 'corenlp';
5874

59-
CoreNLP.setup('English');
75+
CoreNLP.setup('English'); // check method docs for more setup options
6076
const sent = new CoreNLP.simple.Sentence('The little dog runs so fast.');
6177
sent.applyAnnotator(CoreNLP.simple.annotator.ParserAnnotator)
6278
.then(() => {
@@ -73,7 +89,7 @@ sent.applyAnnotator(CoreNLP.simple.annotator.ParserAnnotator)
7389
```javascript
7490
import CoreNLP from 'corenlp';
7591

76-
CoreNLP.setup('Spanish');
92+
CoreNLP.setup('Spanish'); // check method docs for more setup options
7793
const sent = new CoreNLP.simple.Sentence('El pájaro veloz come kiwi.');
7894
sent.applyAnnotator(CoreNLP.simple.annotator.ParserAnnotator)
7995
.then(() => {
@@ -90,29 +106,29 @@ sent.applyAnnotator(CoreNLP.simple.annotator.ParserAnnotator)
90106
We will update this section soon. In the meantime, you can browse the project codebase and read the @jsdoc referenecs.
91107
In summary, this NodeJS library aims to replicate the CoreNLP Simple Java interface but in Javascript. There are some minor differences however, for example the need to call `applyAnnotator` asynchronously.
92108

93-
```
109+
```bash
94110
CoreNLP
95111
connector
96-
ConnectorServer # https://stanfordnlp.github.io/CoreNLP/corenlp-server.html
97-
ConnectorCli # https://stanfordnlp.github.io/CoreNLP/cmdline.html
98-
simple # https://stanfordnlp.github.io/CoreNLP/simple.html
112+
ConnectorServer # https://stanfordnlp.github.io/CoreNLP/corenlp-server.html
113+
ConnectorCli # https://stanfordnlp.github.io/CoreNLP/cmdline.html
114+
simple # https://stanfordnlp.github.io/CoreNLP/simple.html
99115
Annotable
100116
Annotator
101117
Document
102118
Sentence
103119
Token
104-
annotator # https://stanfordnlp.github.io/CoreNLP/annotators.html
105-
TokenizerAnnotator # https://stanfordnlp.github.io/CoreNLP/tokenize.html
106-
WordsToSentenceAnnotator # https://stanfordnlp.github.io/CoreNLP/ssplit.html
107-
POSTaggerAnnotator # https://stanfordnlp.github.io/CoreNLP/pos.html
108-
MorphaAnnotator # https://stanfordnlp.github.io/CoreNLP/lemma.html
109-
NERClassifierCombiner # https://stanfordnlp.github.io/CoreNLP/ner.html
110-
ParserAnnotator # https://stanfordnlp.github.io/CoreNLP/parse.html
111-
DependencyParseAnnotator # https://stanfordnlp.github.io/CoreNLP/depparse.html
112-
RelationExtractorAnnotator # https://stanfordnlp.github.io/CoreNLP/relation.html
120+
annotator # https://stanfordnlp.github.io/CoreNLP/annotators.html
121+
TokenizerAnnotator # https://stanfordnlp.github.io/CoreNLP/tokenize.html
122+
WordsToSentenceAnnotator # https://stanfordnlp.github.io/CoreNLP/ssplit.html
123+
POSTaggerAnnotator # https://stanfordnlp.github.io/CoreNLP/pos.html
124+
MorphaAnnotator # https://stanfordnlp.github.io/CoreNLP/lemma.html
125+
NERClassifierCombiner # https://stanfordnlp.github.io/CoreNLP/ner.html
126+
ParserAnnotator # https://stanfordnlp.github.io/CoreNLP/parse.html
127+
DependencyParseAnnotator # https://stanfordnlp.github.io/CoreNLP/depparse.html
128+
RelationExtractorAnnotator # https://stanfordnlp.github.io/CoreNLP/relation.html
113129
DeterministicCorefAnnotator # https://stanfordnlp.github.io/CoreNLP/coref.html
114130
util
115-
Tree # http://www.cs.cornell.edu/courses/cs474/2004fa/lec1.pdf
131+
Tree # http://www.cs.cornell.edu/courses/cs474/2004fa/lec1.pdf
116132
```
117133

118134
## Stanford CoreNLP Reference

0 commit comments

Comments
 (0)