Permalink
Browse files

started new wordnet transfer (for sqlite)

  • Loading branch information...
1 parent 30b5c1d commit 7908ca9daf4c4d16d43ce6b4ce798b291de49575 @chrisumbel chrisumbel committed Mar 13, 2012
Showing with 58 additions and 25 deletions.
  1. +28 −0 io_spec/wordnet_spec.js
  2. +26 −2 lib/natural/wordnet/wordnet.js
  3. +4 −4 package.json
  4. +0 −19 spec/wordnet_spec.js
View
@@ -0,0 +1,28 @@
+/*
+Copyright (c) 2011, Chris Umbel and Russell Mull
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+var WordNet = require('lib/natural/wordnet/wordnet');
+
+describe('wordnet', function() {
+ it('should download and unzip wordnet if non-existant', function() {
+
+ });
+});
@@ -20,8 +20,32 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-var sqlite3 = require('sqlite3');
-var _ = require('underscore');
+var sqlite3 = require('sqlite3'),
+ _ = require('underscore'),
+ url = require('url');
+
+function downloadFile(url, filePath, callback) {
+ var zlib;
+
+ zlib = require('zlib');
+ var http = require('http');
+
+ var req = http.get({
+ host: url.host,
+ path: url.path,
+ port: 80
+ });
+
+ req.on('response', function (response) {
+ var fileStream = fs.createWriteStream(filePath);
+ response.on('end', function () {
+ fileStream.end();
+ callback();
+ });
+ response.pipe(zlib.createGunzip()).pipe(fileStream);
+ });
+ return;
+}
module.exports = function(dbInfo) {
var db = null;
View
@@ -1,16 +1,16 @@
{
"name": "natural",
"description": "General natural language (tokenizing, stemming, classification, inflection, phonetics, tfidf, WordNet) facilities for node.",
- "version": "0.0.69",
+ "version": "0.1.0",
"homepage": "https://github.com/NaturalNode/natural",
"engines": {
- "node": ">=0.4.9"
+ "node": "0.6.x"
},
"dependencies": {
"sylvester": ">= 0.0.12",
"apparatus": ">= 0.0.4",
- "underscore": "*",
- "sqlite3": "2.1.x"
+ "underscore": ">=1.3.1",
+ "sqlite3": ">=2.1.0"
},
"devDependencies": {
"uubench": "0.0.x"
View
@@ -100,24 +100,5 @@ describe('wordnet', function() {
});
asyncSpecWait();
});
-
- });
-/*
-
- it('should lookup synonyms', function() {
- var wordnet = new WordNet('./io_spec/test_data/wordnet/download/', 'http://wordnet.naturalnode.com/');
-
- wordnet.lookupSynonyms('entity', function(records) {
- expect(records.length).toBe(3);
-
- require('path').exists('./io_spec/test_data/wordnet/download/index.noun', function(exists) {
- expect(exists).toBeTruthy();
- asyncSpecDone();
- });
- });
-
- asyncSpecWait();
});
-
-*/
});

0 comments on commit 7908ca9

Please sign in to comment.