Skip to content
This repository
Newer
Older
100644 501 lines (336 sloc) 17.434 kb
07d8afa0 » chrisumbel
2011-05-06 markdown-ified readme
1 natural
4badede2 » chrisumbel
2011-05-06 markdown-ified readme
2 =======
98310f8f » chrisumbel
2011-05-06 initial import
3
5af97ad9 » chrisumbel
2011-08-30 tweaked docs
4 "Natural" is a general natural language facility for nodejs. Tokenizing,
c471ae9d » Chris Umbel
2012-03-13 added basic test for Jaro-Winkler distance
5 stemming, classification, phonetics, tf-idf, WordNet, string similarity,
6 and some inflection are currently supported.
98310f8f » chrisumbel
2011-05-06 initial import
7
e34dc027 » chrisumbel
2011-08-20 update README for new features, ticked to 0.0.42
8 It's still in the early stages, and am very interested in bug reports,
9 contributions and the like.
6dd196a3 » chrisumbel
2011-05-16 added SoundEx, ticked version
10
34073f51 » chrisumbel
2011-08-30 added note to readme about nltools merge
11 Note that many algorithms from Rob Ellis's [node-nltools](https://github.com/NaturalNode/node-nltools) are
12 being merged in to this project and will be maintained here going forward.
13
6dd196a3 » chrisumbel
2011-05-16 added SoundEx, ticked version
14 At the moment most algorithms are English-specific but long-term some diversity
ce54232d » chrisumbel
2011-05-16 added handling for arrays of tokens in Bayes classifier.
15 is in order.
16
164d379e » chrisumbel
2011-06-05 updated README to include link to the only other existing usage docum…
17 Aside from this README the only current documentation is [here on my blog](http://www.chrisumbel.com/article/node_js_natural_language_porter_stemmer_lancaster_bayes_naive_metaphone_soundex).
18
be9bfd2b » chrisumbel
2011-05-16 added install instructions
19 Installation
20 ------------
21
22 If you're just looking to consume natural without your own node application
23 please install the NPM
24
25 npm install natural
26
6dd196a3 » chrisumbel
2011-05-16 added SoundEx, ticked version
27 If you're interested in contributing to natural or just hacking it then by all
28 means fork away!
29
a0217db4 » chrisumbel
2011-08-30 added tokenizer docs
30 Tokenizers
31 ----------
32
33 Word, Regexp and Treebank tokenizers are provided for breaking text up into
34 arrays of tokens.
35
36 var natural = require('natural'),
37 tokenizer = new natural.WordTokenizer();
38 console.log(tokenizer.tokenize("your dog has flees."));
39 // [ 'your', 'dog', 'has', 'flees' ]
40
41 The other tokenizers follow a similar pattern
42
43 tokenizer = new natural.TreebankWordTokenizer();
44 console.log(tokenizer.tokenize("my dog hasn't any flees."));
45 // [ 'my', 'dog', 'has', 'n\'t', 'any', 'flees', '.' ]
46
47 tokenizer = new natural.RegexpTokenizer({pattern: /\-/});
48 console.log(tokenizer.tokenize("flee-dog"));
49 // [ 'flee', 'dog' ]
c471ae9d » Chris Umbel
2012-03-13 added basic test for Jaro-Winkler distance
50
51 String Similiarity
52 ---------------
53
54 The similiarity between two strings can be accomplished with a Jaro–Winkler distance.
55
56 var jaroWinklerDistance = require('natural').JaroWinklerDistance;
57
58 console.log('apple', 'applet'); // outputs 0.9666666666666667
59 console.log(d('not', 'same')); // output NaN
a0217db4 » chrisumbel
2011-08-30 added tokenizer docs
60
c4ad90c7 » chrisumbel
2011-05-12 updated README for lancaster. fixed improper handling of first token …
61 Stemmers
62 --------
63
64 Currently stemming is supported via the Porter and Lancaster (Paice/Husk)
65 algorithms.
66
c9534eba » chrisumbel
2011-05-11 ticked to 4. made modules more idiomatic
67 var natural = require('natural');
c4ad90c7 » chrisumbel
2011-05-12 updated README for lancaster. fixed improper handling of first token …
68
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
69 this example uses a porter stemmer. "word" is returned.
70
c4ad90c7 » chrisumbel
2011-05-12 updated README for lancaster. fixed improper handling of first token …
71 console.log(natural.PorterStemmer.stem("words")); // stem a single word
72
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
73 attach() patches stem() and tokenizeAndStem() to String as a shortcut to
74 PorterStemmer.stem(token). tokenizeAndStem() breaks text up into single words
75 and returns an array of stemmed tokens.
76
c9534eba » chrisumbel
2011-05-11 ticked to 4. made modules more idiomatic
77 natural.PorterStemmer.attach();
f715ee84 » chrisumbel
2011-05-06 added examples
78 console.log("i am waking up to the sounds of chainsaws".tokenizeAndStem());
c4ad90c7 » chrisumbel
2011-05-12 updated README for lancaster. fixed improper handling of first token …
79 console.log("chainsaws".stem());
7b230758 » chrisumbel
2011-05-06 added examples
80
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
81 the same thing can be done with a lancaster stemmer
82
c4ad90c7 » chrisumbel
2011-05-12 updated README for lancaster. fixed improper handling of first token …
83 natural.LancasterStemmer.attach();
84 console.log("i am waking up to the sounds of chainsaws".tokenizeAndStem());
5fc5055f » chrisumbel
2011-05-06 added examples
85 console.log("chainsaws".stem());
86
2e602203 » chrisumbel
2011-11-27 classification uses apparatus now
87 Classifiers
7b230758 » chrisumbel
2011-05-06 added examples
88 ----------------------
89
2e602203 » chrisumbel
2011-11-27 classification uses apparatus now
90 Two classifiers are currently supported, Naive Bayes and logistic regression.
91 The following examples use the BayesClassifier class, but the
92 LogisticRegressionClassifier class could be substituted instead.
93
c9534eba » chrisumbel
2011-05-11 ticked to 4. made modules more idiomatic
94 var natural = require('natural'),
95 classifier = new natural.BayesClassifier();
7b230758 » chrisumbel
2011-05-06 added examples
96
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
97 you can train the classifier on sample text. it will use reasonable defaults to
98 tokenize and stem the text.
2e602203 » chrisumbel
2011-11-27 classification uses apparatus now
99
100 classifier.addDocument('i am long qqqq', 'buy');
101 classifier.addDocument('buy the q's', 'buy');
102 classifier.addDocument('short gold', 'sell');
103 classifier.addDocument('sell gold', 'sell');
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
104
2e602203 » chrisumbel
2011-11-27 classification uses apparatus now
105 classifier.train();
7b230758 » chrisumbel
2011-05-06 added examples
106
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
107 outputs "sell"
108
2a1b7fd8 » chrisumbel
2011-05-06 added examples
109 console.log(classifier.classify('i am short silver'));
7b230758 » chrisumbel
2011-05-06 added examples
110
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
111 outputs "buy"
112
2a1b7fd8 » chrisumbel
2011-05-06 added examples
113 console.log(classifier.classify('i am long copper'));
7b230758 » chrisumbel
2011-05-06 added examples
114
90521f00 » adamb0mb
2012-03-10 updated README to include getClassifications example (after I spent t…
115 you have access to the set of matched classes and the associated value from the classifier.
116
117 outputs:
1a7d862d » adamb0mb
2012-03-10 updated README to include getClassifications example (after I spent t…
118
90521f00 » adamb0mb
2012-03-10 updated README to include getClassifications example (after I spent t…
119 [ { label: 'sell', value: 0.39999999999999997 },
120 { label: 'buy', value: 0.19999999999999998 } ]
121
122 from this:
1a7d862d » adamb0mb
2012-03-10 updated README to include getClassifications example (after I spent t…
123
90521f00 » adamb0mb
2012-03-10 updated README to include getClassifications example (after I spent t…
124 console.log(classifier.getClassifications('i am long copper'));
125
ce54232d » chrisumbel
2011-05-16 added handling for arrays of tokens in Bayes classifier.
126
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
127 the classifier can also be trained on and classify arrays of tokens, strings, or
128 any mixture. arrays let you use entirely custom data with your own
129 tokenization/stemming if any at all.
130
2e602203 » chrisumbel
2011-11-27 classification uses apparatus now
131 classifier.addDocument(['sell', 'gold'], 'sell');
65c2d93a » chrisumbel
2011-05-17 added docs for classifier persistence
132
2e602203 » chrisumbel
2011-11-27 classification uses apparatus now
133 A classifier can also be persisted and recalled so you can reuse a training
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
134
f0a571ce » chrisumbel
2011-05-19 corrected param order in docs for classifier saving
135 classifier.save('classifier.json', function(err, classifier) {
65c2d93a » chrisumbel
2011-05-17 added docs for classifier persistence
136 // the classifier is saved to the classifier.json file!
137 });
138
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
139 and to recall from the classifier.json saved above:
140
2e602203 » chrisumbel
2011-11-27 classification uses apparatus now
141 natural.BayesClassifier.load('classifier.json', null, function(err, classifier) {
65c2d93a » chrisumbel
2011-05-17 added docs for classifier persistence
142 console.log(classifier.classify('long SUNW'));
143 console.log(classifier.classify('short SUNW'));
144 });
ce54232d » chrisumbel
2011-05-16 added handling for arrays of tokens in Bayes classifier.
145
56196ba7 » chrisumbel
2011-07-20 updated README with new classifier serialization
146 A classifier can also be serialized and deserialized as such
147
148 var classifier = new natural.BayesClassifier();
2e602203 » chrisumbel
2011-11-27 classification uses apparatus now
149 classifier.addDocument(['sell', 'gold'], 'sell');
150 classifier.addDocument(['buy', 'silver'], 'buy');
56196ba7 » chrisumbel
2011-07-20 updated README with new classifier serialization
151
9a9192f4 » chrisumbel
2011-07-20 clarified docs for classifier serlialization
152 // serialize
56196ba7 » chrisumbel
2011-07-20 updated README with new classifier serialization
153 var raw = JSON.stringify(classifier);
9a9192f4 » chrisumbel
2011-07-20 clarified docs for classifier serlialization
154 // deserialize
56196ba7 » chrisumbel
2011-07-20 updated README with new classifier serialization
155 var restoredClassifier = natural.BayesClassifier.restore(raw);
2e602203 » chrisumbel
2011-11-27 classification uses apparatus now
156 console.log(restoredClassifier.classify('i should sell that'));
56196ba7 » chrisumbel
2011-07-20 updated README with new classifier serialization
157
6dd196a3 » chrisumbel
2011-05-16 added SoundEx, ticked version
158 Phonetics
159 ---------
760840a3 » chrisumbel
2011-05-15 added main interface functions for Metaphone
160
4816ca0e » chrisumbel
2012-02-16 added DoubleMetaphone compare and exposed DM
161 Phonetic matching (sounds-like) matching can be done withthe SoundEx,
162 Metaphone or DoubleMetaphone algorithms
6dd196a3 » chrisumbel
2011-05-16 added SoundEx, ticked version
163
164 var natural = require('natural'),
165 metaphone = natural.Metaphone, soundEx = natural.SoundEx;
760840a3 » chrisumbel
2011-05-15 added main interface functions for Metaphone
166
167 var wordA = 'phonetics';
168 var wordB = 'fonetix';
169
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
170 test the two words to see if they sound alike
171
760840a3 » chrisumbel
2011-05-15 added main interface functions for Metaphone
172 if(metaphone.compare(wordA, wordB))
173 console.log('they sound alike!');
ce54232d » chrisumbel
2011-05-16 added handling for arrays of tokens in Bayes classifier.
174
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
175 the raw phonetics are obtained with process()
176
32669913 » chrisumbel
2011-05-16 corrected metaphone examples
177 console.log(metaphone.process('phonetics'));
760840a3 » chrisumbel
2011-05-15 added main interface functions for Metaphone
178
d769c71a » chrisumbel
2012-02-20 ticked to 0.0.69 with maxLength support
179 a maximum code length can be supplied
180
181 console.log(metaphone.process('phonetics', 3));
182
5b1684d2 » chrisumbel
2012-02-26 README formatting
183 DoubleMetaphone deals with two encodings returned in an array. This
184 feature is experimental and subject to change.
185
186 var natural = require('natural'),
8a2c8d4f » chrisumbel
2012-03-05 corrected doublemetaphone example
187 dm = natural.DoubleMetaphone;
5b1684d2 » chrisumbel
2012-02-26 README formatting
188
189 var encodings = dm.process('Matrix');
190 console.log(encodings[0]);
191 console.log(encodings[1]);
192
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
193 attaching will patch String with useful methods
194
760840a3 » chrisumbel
2011-05-15 added main interface functions for Metaphone
195 metaphone.attach();
196
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
197 soundsLike is essentially a shortcut to Metaphone.compare
198
760840a3 » chrisumbel
2011-05-15 added main interface functions for Metaphone
199 if(wordA.soundsLike(wordB))
ce54232d » chrisumbel
2011-05-16 added handling for arrays of tokens in Bayes classifier.
200 console.log('they sound alike!');
201
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
202 the raw phonetics are obtained with phonetics()
203
6dd196a3 » chrisumbel
2011-05-16 added SoundEx, ticked version
204 console.log('phonetics'.phonetics());
205
f4785731 » chrisumbel
2011-05-21 updated docs with tokenizeAndPhoneticize example
206 full text strings can be tokenized into arrays of phonetics similar to stemmers
207
208 console.log('phonetics rock'.tokenizeAndPhoneticize());
209
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
210 same module operations apply with SoundEx
211
6dd196a3 » chrisumbel
2011-05-16 added SoundEx, ticked version
212 if(soundEx.compare(wordA, wordB))
213 console.log('they sound alike!');
214
b7f741a5 » chrisumbel
2011-05-17 cleaned up README
215 the same String patches apply with soundex
216
6dd196a3 » chrisumbel
2011-05-16 added SoundEx, ticked version
217 soundEx.attach();
218
219 if(wordA.soundsLike(wordB))
220 console.log('they sound alike!');
221
65c2d93a » chrisumbel
2011-05-17 added docs for classifier persistence
222 console.log('phonetics'.phonetics());
a809bb03 » chrisumbel
2011-05-21 added doc for inflectors
223
f4785731 » chrisumbel
2011-05-21 updated docs with tokenizeAndPhoneticize example
224
a809bb03 » chrisumbel
2011-05-21 added doc for inflectors
225 Inflectors
226 ----------
227
e34dc027 » chrisumbel
2011-08-20 update README for new features, ticked to 0.0.42
228 ### Nouns
229
230 Nouns can be pluralized/singularized with a NounInflector
a809bb03 » chrisumbel
2011-05-21 added doc for inflectors
231
232 var natural = require('natural'),
e34dc027 » chrisumbel
2011-08-20 update README for new features, ticked to 0.0.42
233 nounInflector = new natural.NounInflector();
a809bb03 » chrisumbel
2011-05-21 added doc for inflectors
234
235 to pluralize a word (outputs "radii")
236
237 console.log(nounInflector.pluralize('radius'));
238
239 to singularize a word (outputs "beer")
240
241 console.log(nounInflector.singularize('beers'));
242
e34dc027 » chrisumbel
2011-08-20 update README for new features, ticked to 0.0.42
243 Like many of the other features String can be patched to perform the operations
244 directly. The "Noun" suffix to the methods is necessary as verbs will be
a809bb03 » chrisumbel
2011-05-21 added doc for inflectors
245 supported in the future.
246
247 nounInflector.attach();
248 console.log('radius'.pluralizeNoun());
249 console.log('beers'.singularizeNoun());
250
e34dc027 » chrisumbel
2011-08-20 update README for new features, ticked to 0.0.42
251 ### Numbers
252
253 Numbers can be counted with a CountInflector
254
255 var countInflector = natural.CountInflector;
a809bb03 » chrisumbel
2011-05-21 added doc for inflectors
256
257 outputs "1st"
258
259 console.log(countInflector.nth(1));
260
261 outputs "111th"
262
263 console.log(countInflector.nth(111));
264
e34dc027 » chrisumbel
2011-08-20 update README for new features, ticked to 0.0.42
265 ### Present Tense Verbs
266
267 Present Tense Verbs can be pluralized/singularized with a PresentVerbInflector.
268 This feature is still experimental as of 0.0.42 so use with caution and please
269 provide feedback.
270
271 var verbInflector = new natural.PresentVerbInflector();
272
273 outputs "becomes"
274
275 console.log(verbInflector.singularize('become'));
276
277 outputs "become"
278
279 console.log(verbInflector.pluralize('becomes'));
280
281 Like many other natural modules attach() can be used to patch strings with
282 handy methods.
283
284 verbInflector.attach();
285 console.log('walk'.singularizePresentVerb());
286 console.log('walks'.pluralizePresentVerb());
287
288
3074221e » chrisumbel
2011-08-30 added n-gram docs, ticked version
289 N-Grams
51cf8846 » chrisumbel
2011-08-30 formatting of n-gram header
290 -------
3074221e » chrisumbel
2011-08-30 added n-gram docs, ticked version
291
292 n-grams can be obtained for either arrays or strings (which will be tokenized
293 for you)
294
295 var NGrams = natural.NGrams;
296
678473fe » chrisumbel
2011-08-30 formatting of n-grams
297 ### bigrams
3074221e » chrisumbel
2011-08-30 added n-gram docs, ticked version
298
299 console.log(NGrams.bigrams('some words here'));
300 console.log(NGrams.bigrams(['some', 'words', 'here']));
301
302 both of which output [ [ 'some', 'words' ], [ 'words', 'here' ] ]
303
678473fe » chrisumbel
2011-08-30 formatting of n-grams
304 ### trigrams
3074221e » chrisumbel
2011-08-30 added n-gram docs, ticked version
305
306 console.log(NGrams.trigrams('some other words here'));
307 console.log(NGrams.trigrams(['some', 'other', 'words', 'here']));
308
309 both of which output [ [ 'some', 'other', 'words' ],
310 [ 'other', 'words', 'here' ] ]
311
678473fe » chrisumbel
2011-08-30 formatting of n-grams
312 ### arbitrary n-grams
3074221e » chrisumbel
2011-08-30 added n-gram docs, ticked version
313
314 console.log(NGrams.ngrams('some other words here for you', 4));
315 console.log(NGrams.ngrams(['some', 'other', 'words', 'here', 'for',
316 'you'], 4));
317
318 which outputs [ [ 'some', 'other', 'words', 'here' ],
319 [ 'other', 'words', 'here', 'for' ],
320 [ 'words', 'here', 'for', 'you' ] ]
321
ea5ff31a » chrisumbel
2011-09-14 clarified some README headings
322 tf-idf
7e241b28 » chrisumbel
2011-09-04 added tfidf docs for initial version, ticked to 0.0.50
323 -----
324
ea5ff31a » chrisumbel
2011-09-14 clarified some README headings
325 Term Frequency–Inverse Document Frequency (tf-idf) is implemented to determine how important a word (or words) is to a
ae972e1c » chrisumbel
2011-09-04 clarified language in tfidf
326 document relative to a corpus. The following example will add four documents to
327 a corpus and determine the weight of the word "node" and then the weight of the
328 word "ruby" in each document.
329
7e241b28 » chrisumbel
2011-09-04 added tfidf docs for initial version, ticked to 0.0.50
330 var natural = require('natural'),
331 TfIdf = natural.TfIdf,
332 tfidf = new TfIdf();
333
334 tfidf.addDocument('this document is about node.');
335 tfidf.addDocument('this document is about ruby.');
336 tfidf.addDocument('this document is about ruby and node.');
337 tfidf.addDocument('this document is about node. it has node examples');
338
00decf32 » chrisumbel
2011-09-04 added single document measure to readme
339 console.log('node --------------------------------');
7e241b28 » chrisumbel
2011-09-04 added tfidf docs for initial version, ticked to 0.0.50
340 tfidf.tfidfs('node', function(i, measure) {
341 console.log('document #' + i + ' is ' + measure);
342 });
343
00decf32 » chrisumbel
2011-09-04 added single document measure to readme
344 console.log('ruby --------------------------------');
345 tfidf.tfidfs('ruby', function(i, measure) {
346 console.log('document #' + i + ' is ' + measure);
347 });
348
7e241b28 » chrisumbel
2011-09-04 added tfidf docs for initial version, ticked to 0.0.50
349 which outputs
350
00decf32 » chrisumbel
2011-09-04 added single document measure to readme
351 node --------------------------------
7e241b28 » chrisumbel
2011-09-04 added tfidf docs for initial version, ticked to 0.0.50
352 document #0 is 1.4469189829363254
353 document #1 is 0
354 document #2 is 1.4469189829363254
355 document #3 is 2.8938379658726507
00decf32 » chrisumbel
2011-09-04 added single document measure to readme
356 ruby --------------------------------
357 document #0 is 0
358 document #1 is 1.466337068793427
359 document #2 is 1.466337068793427
360 document #3 is 0
361
362 Of course you can measure a single document. The following example measures
363 the term "node" in the first and second documents.
364
365 console.log(tfidf.tfidf('node', 0));
366 console.log(tfidf.tfidf('node', 1));
7e241b28 » chrisumbel
2011-09-04 added tfidf docs for initial version, ticked to 0.0.50
367
482bec1b » chrisumbel
2011-09-04 clarified file loading
368 A TfIdf instance can also load documents from files on disk.
369
370 var tfidf = new TfIdf();
371 tfidf.addFileSync('data_files/one.txt');
372 tfidf.addFileSync('data_files/two.txt');
373
7e241b28 » chrisumbel
2011-09-04 added tfidf docs for initial version, ticked to 0.0.50
374 Multiple terms can be measured as well with their weights being added into
375 a single measure value. The following example determines that the last document
376 is the most relevent to the words "node" and "ruby".
377
378 var natural = require('natural'),
379 TfIdf = natural.TfIdf,
380 tfidf = new TfIdf();
381
382 tfidf.addDocument('this document is about node.');
383 tfidf.addDocument('this document is about ruby.');
384 tfidf.addDocument('this document is about ruby and node.');
385
386 tfidf.tfidfs('node ruby', function(i, measure) {
387 console.log('document #' + i + ' is ' + measure);
388 });
389
390 which outputs
391
392 document #0 is 1.2039728043259361
393 document #1 is 1.2039728043259361
394 document #2 is 2.4079456086518722
395
396 The examples above all use strings in which case natural will tokenize the input.
397 If you wish to perform your own tokenization or other kinds of processing you
398 can do so and then pass in the resultant arrays. That will cause natural to
399 bypass its own preprocessing.
400
401 var natural = require('natural'),
402 TfIdf = natural.TfIdf,
403 tfidf = new TfIdf();
404
405 tfidf.addDocument(['document', 'about', 'node']);
406 tfidf.addDocument(['document', 'about', 'ruby']);
407 tfidf.addDocument(['document', 'about', 'ruby', 'node']);
408 tfidf.addDocument(['document', 'about', 'node', 'node', 'examples']);
409
410 tfidf.tfidfs(['node', 'ruby'], function(i, measure) {
411 console.log('document #' + i + ' is ' + measure);
412 });
413
d6c2448a » chrisumbel
2011-09-26 tfidf can list terms for a document
414 It's possible to retrieve a list of all terms in a document sorted by their
415 importance.
416
417 tfidf.listTerms(0 /*document index*/).forEach(function(item) {
418 console.log(item.term + ': ' + item.tfidf);
419 });
420
19435557 » chrisumbel
2011-09-04 add ability for TfIdf to load files
421 A TfIdf instance can also be serialized and deserialzed for save and recall.
422
423 var tfidf = new TfIdf();
424 tfidf.addDocument('document one', 'un');
425 tfidf.addDocument('document Two', 'deux');
426 var s = JSON.stringify(tfidf);
427 // save "s" to disk, database or otherwise
428
429 // assuming you pulled "s" back out of storage.
430 var tfidf = new TfIdf(JSON.parse(s));
431
b2fc2e3f » chrisumbel
2011-08-14 buffer doenst overflow for long synsets in data file
432 WordNet
433 -------
434
67e2614a » mullr
2012-03-12 Use sqlite for wordnet integration
435 Natural provides a partial wrapper over the WordNet database. To use it,
436 you'll need to download the sqlite version of the database from
2c69e90a » chrisumbel
2012-03-13 added link to our hosted copy of wordnet
437 http://sourceforge.net/projects/wnsql/files/ or http://wordnet.naturalnode.com/wordnet30-sqlite-1.0.1.zip and put it somewhere on your system.
67e2614a » mullr
2012-03-12 Use sqlite for wordnet integration
438 Then, pass in the path to the database when calling the WordNet constructor.
b2fc2e3f » chrisumbel
2011-08-14 buffer doenst overflow for long synsets in data file
439
f197b2b3 » chrisumbel
2011-08-14 ticked to 0.29, docs updated
440 Keep in mind the WordNet integration is to be considered experimental at this point
e34dc027 » chrisumbel
2011-08-20 update README for new features, ticked to 0.0.42
441 and not production ready. The API is also subject to change.
f197b2b3 » chrisumbel
2011-08-14 ticked to 0.29, docs updated
442
29217c7c » chrisumbel
2011-08-16 beefed up wordnet examples in docs
443 Here's an exmple of looking up definitions for the word, "node".
444
67e2614a » mullr
2012-03-12 Use sqlite for wordnet integration
445 var wordnet = new natural.WordNet('./wordnet30.sqlite');
b2fc2e3f » chrisumbel
2011-08-14 buffer doenst overflow for long synsets in data file
446
67e2614a » mullr
2012-03-12 Use sqlite for wordnet integration
447 wordnet.getWord('node', function(word) {
448 console.log(word.lemma);
449 word.senses.forEach(function(sense) {
b2fc2e3f » chrisumbel
2011-08-14 buffer doenst overflow for long synsets in data file
450 console.log('------------------------------------');
67e2614a » mullr
2012-03-12 Use sqlite for wordnet integration
451 console.log(sense.definition);
452 console.log(sense.pos);
453 sense.getSynonyms(function(synonymns) {
897be498 » mullr
2012-03-12 Fix examples in README.md
454 synonymns.forEach(function(synonymn) {
67e2614a » mullr
2012-03-12 Use sqlite for wordnet integration
455 console.log("- " + synonymn.lemma);
456 });
457 });
b2fc2e3f » chrisumbel
2011-08-14 buffer doenst overflow for long synsets in data file
458 });
459 });
29217c7c » chrisumbel
2011-08-16 beefed up wordnet examples in docs
460
67e2614a » mullr
2012-03-12 Use sqlite for wordnet integration
461 You can also search for multiple words, using '%' as a wildcard.
29217c7c » chrisumbel
2011-08-16 beefed up wordnet examples in docs
462
67e2614a » mullr
2012-03-12 Use sqlite for wordnet integration
463 wordnet.findWords("nod%", function(words) {
897be498 » mullr
2012-03-12 Fix examples in README.md
464 words.forEach(function(word) {
67e2614a » mullr
2012-03-12 Use sqlite for wordnet integration
465 console.log(word.lemma);
466 });
29217c7c » chrisumbel
2011-08-16 beefed up wordnet examples in docs
467 });
b2fc2e3f » chrisumbel
2011-08-14 buffer doenst overflow for long synsets in data file
468
67e2614a » mullr
2012-03-12 Use sqlite for wordnet integration
469
b2fc2e3f » chrisumbel
2011-08-14 buffer doenst overflow for long synsets in data file
470 Princeton University "About WordNet." WordNet. Princeton University. 2010. <http://wordnet.princeton.edu>
760840a3 » chrisumbel
2011-05-15 added main interface functions for Metaphone
471
f6285235 » chrisumbel
2011-05-27 added license to README and examples
472 License
473 -------
474
67e2614a » mullr
2012-03-12 Use sqlite for wordnet integration
475 Copyright (c) 2011, Chris Umbel, Rob Ellis, Russell Mull
f6285235 » chrisumbel
2011-05-27 added license to README and examples
476
477 Permission is hereby granted, free of charge, to any person obtaining a copy
478 of this software and associated documentation files (the "Software"), to deal
479 in the Software without restriction, including without limitation the rights
480 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
481 copies of the Software, and to permit persons to whom the Software is
482 furnished to do so, subject to the following conditions:
483
484 The above copyright notice and this permission notice shall be included in
485 all copies or substantial portions of the Software.
486
487 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
488 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
489 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
490 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
491 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
492 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
493 THE SOFTWARE.
490478cc » chrisumbel
2011-08-14 added WordNet license
494
495 WordNet License
496 ---------------
497
498 This license is available as the file LICENSE in any downloaded version of WordNet.
499 WordNet 3.0 license: (Download)
500
67e2614a » mullr
2012-03-12 Use sqlite for wordnet integration
501 WordNet Release 3.0 This software and database is being provided to you, the LICENSEE, by Princeton University under the following license. By obtaining, using and/or copying this software and database, you agree that you have read, understood, and will comply with these terms and conditions.: Permission to use, copy, modify and distribute this software and database and its documentation for any purpose and without fee or royalty is hereby granted, provided that you agree to comply with the following copyright notice and statements, including the disclaimer, and that the same appear on ALL copies of the software, database and documentation, including modifications that you make for internal use or for distribution. WordNet 3.0 Copyright 2006 by Princeton University. All rights reserved. THIS SOFTWARE AND DATABASE IS PROVIDED "AS IS" AND PRINCETON UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PRINCETON UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCHANT- ABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE, DATABASE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. The name of Princeton University or Princeton may not be used in advertising or publicity pertaining to distribution of the software and/or database. Title to copyright in this software, database and any associated documentation shall at all times remain with Princeton University and LICENSEE agrees to preserve same.
Something went wrong with that request. Please try again.