Skip to content

Commit 77cfd03

Browse files
committed
Updated comments, added package.json, updated .gitignore
1 parent ccba87b commit 77cfd03

File tree

4 files changed

+99
-44
lines changed

4 files changed

+99
-44
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ logs
1313
results
1414

1515
npm-debug.log
16+
example/StanfordCoreNLP.properties
17+
example/config.json

example/example-as-package.js

+43-37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/example-as-package.ts

+33-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
1-
/*
2-
* This program tests the StanfordCoreNLP node wrapper.
1+
/* *
2+
* This program tests the stanford-corenlp-node package.
3+
* Usage:
4+
* >
5+
* > cd my_projects_dir
6+
* > git clone [email protected]:mhewett/stanford-corenlp-node-example.git
7+
* > npm install
8+
* >
9+
* > cd stanford-corenlp-node-example/example
10+
* > cp StanfordCoreNLP.example.properties StanfordCoreNLP.properties
11+
* > cp config.example.json config.json
12+
* >
13+
* > [ edit config.json; ensure that "path", "nlpLibDir", and "propsPath" are set correctly]
14+
* > [ edit StanfordCoreNLP.properties; ensure that the path to the NER dictionary is correct ]
15+
* >
16+
* > # finally we are ready to run!
17+
* > node example-as-package ./config.json
18+
* >
19+
*
20+
* Mike Hewett
21+
* Dec 2012
22+
323
*/
24+
25+
// These are required for TypeScript
426
declare var require, process;
27+
28+
// Third-party Node.js packages
529
var events = require("minpubsub/minpubsub");
630
var nlplib = require("stanford-corenlp-node");
731

8-
// Events
32+
// Event declarations
933
var SERVER_AVAILABLE = "Server started";
1034

1135
// Create an instance of the server, passing in the config file.
1236
var nlpServer = new nlplib.StanfordCoreNLP.Server(process.argv[2]);
13-
console.log("NLP server status: ", nlpServer.getStatus().getState());
1437

1538
// Start the server. This is an asynchronous call.
1639
// The callback will be run when the NLP library is ready (~20 seconds).
@@ -34,7 +57,10 @@ var testNLP = function() {
3457
switch (counter) {
3558
case 1 : testString = "Bill Clinton was president from 1992 to 2000. He is not the president any more."; break;
3659
case 2 : testString = "Santa Claus is coming to town."; break;
37-
case 3 : nlpServer.stop();
60+
case 3 : console.log("NLP server status: ", nlpServer.getStatus().getState());
61+
events.publish(SERVER_AVAILABLE);
62+
break;
63+
case 4 : nlpServer.stop(); break;
3864
}
3965

4066
// Process the string using the NLP library and print the result.
@@ -43,10 +69,10 @@ var testNLP = function() {
4369
nlpServer.process(testString,
4470
function(result) {
4571
console.log(JSON.stringify(JSON.parse(result), null, " "));
46-
events.publish(SERVER_AVAILABLE, testNLP);
72+
events.publish(SERVER_AVAILABLE);
4773
});
4874
}
4975
}
5076

51-
//Start the test loop by subscribing to the event.
77+
// Ready the loop by subscribing to the event.
5278
events.subscribe(SERVER_AVAILABLE, testNLP);

package.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"author": "LEM Labs, Inc",
3+
"name": "stanford-corenlp-node-example",
4+
"main": "./example/example-as-package",
5+
"description": "Examples of using the stanford-corenlp-node package to access the Stanford CoreNLP library",
6+
"version": "0.1.0",
7+
"homepage": "",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/mhewett/stanford-corenlp-node-example"
11+
},
12+
"engines": {
13+
"node": "~0.8.14"
14+
},
15+
"scripts": {},
16+
"dependencies": {
17+
"minpubsub": "~0.x",
18+
"typescript": "~0.8",
19+
"stanford-corenlp-node": "git+ssh://[email protected]:mhewett/stanford-corenlp-node"
20+
}
21+
}

0 commit comments

Comments
 (0)