Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit d0cb44d65d92850bce8db6219cee3ecb2b04361b @thisandagain committed Oct 2, 2012
Showing with 244 additions and 0 deletions.
  1. +9 −0 .gitignore
  2. +4 −0 .travis.yml
  3. +7 −0 LICENSE.md
  4. +17 −0 README.md
  5. +86 −0 lib/index.js
  6. +7 −0 makefile
  7. +29 −0 package.json
  8. +39 −0 test/debt.js
  9. +46 −0 test/index.js
@@ -0,0 +1,9 @@
+/* MacOS */
+.DS_Store
+
+/* NPM */
+/node_modules
+npm*
+
+/* Other */
+.notes.txt
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
@@ -0,0 +1,7 @@
+Copyright (c) 2012 Andrew Sliwinski.
+
+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.
@@ -0,0 +1,17 @@
+## troll
+#### Language sentiment analysis... for trolls.
+
+### Installation
+```bash
+npm install troll
+```
+
+### Basic Use
+```javascript
+var troll = require('troll');
+```
+
+### Testing
+```bash
+npm test
+```
@@ -0,0 +1,86 @@
+/**
+ * Language sentiment analysis and neural networks... for trolls.
+ *
+ * @package troll
+ * @author Andrew Sliwinski <andrew@diy.org>
+ */
+
+/**
+ * Dependencies
+ */
+var _ = require('underscore'),
+ async = require('async'),
+ sentiment = require('sentiment');
+
+/**
+ * Constructor
+ */
+function Troll (redis) {
+ var self = this;
+
+ _.defaults(redis, {
+ host: null,
+ port: null
+ });
+
+ self.analyze = sentiment.analyze;
+ self.redis = redis.createClient(redis);
+};
+
+/**
+ * Performs sentiment analysis on a given input.
+ *
+ * @param {String} Input text
+ * @param {String} Unique user identifier (optional) for tracking
+ *
+ * @return {Number}
+ */
+Troll.prototype.analyze = function (input, user, callback) {
+ // Process args
+ if (typeof callback === 'undefined') {
+ callback = user;
+ user = null;
+ }
+
+ // Analyze input
+ var result = self.analyze(input);
+
+ // Associate
+
+};
+
+/**
+ * Checks the status of a specified user.
+ *
+ * @param {String} Unique user identifier
+ *
+ * @return {Object}
+ * - user {String} User identity
+ * - total {Number} Total number of analyses performed
+ * - average {Number} Average rating
+ * - troll {Boolean} Is this user a troll?
+ */
+Troll.prototype.lookup = function (user, callback) {
+ // Fetch list from datastore
+
+ // Parse
+
+ // Calc
+};
+
+/**
+ * Trains the neural troll detection network.
+ *
+ * @param {String} Unique user identifier
+ * @param {Boolean} Is troll?
+ *
+ * @return {Err}
+ */
+Troll.prototype.train = function (user, troll, callback) {
+ // body...
+};
+
+/**
+ * Export
+ */
+module.exports = Troll;
@@ -0,0 +1,7 @@
+generator:
+ npm install
+ git init
+ git add -A
+ git remote add origin https://thisandagain@github.com/thisandagain/troll
+
+.PHONY: generator
@@ -0,0 +1,29 @@
+{
+ "author": "Andrew Sliwinski <andrewsliwinski@acm.org> (http://andrewsliwinski.com)",
+ "name": "troll",
+ "description": "Language sentiment analysis... for trolls.",
+ "version": "0.0.1",
+ "homepage": "https://github.com/thisandagain/troll",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/thisandagain/troll.git"
+ },
+ "main": "./lib/index.js",
+ "scripts": {
+ "test": "tap ./test/*.js"
+ },
+ "dependencies": {
+ "async": "~0.1.22",
+ "underscore": "~1.4.1",
+ "Sentimental": "0.0.2",
+ "redis": "~0.8.1"
+ },
+ "devDependencies": {
+ "tap": "~0.3.1",
+ "codebux": "~0.1.2"
+ },
+ "optionalDependencies": {},
+ "engines": {
+ "node": ">=0.6"
+ }
+}
@@ -0,0 +1,39 @@
+/**
+ * Unit test suite.
+ *
+ * @package generator
+ * @author Andrew Sliwinski <andrew@diy.org>
+ */
+
+/**
+ * Dependencies
+ */
+var async = require('async'),
+ test = require('tap').test,
+ bux = require('codebux');
+
+/**
+ * Suite
+ */
+async.auto({
+
+ debt: function (callback) {
+ bux(__dirname + '/../lib', callback);
+ },
+
+ test: ['debt', function (callback, obj) {
+ test('Debt', function (t) {
+ t.type(obj.debt, 'number', 'Results should be a number');
+ t.ok(obj.debt > 50, 'Total should be greater than 50');
+ t.end();
+ });
+
+ callback();
+ }]
+
+}, function (err, obj) {
+ test('Catch errors', function (t) {
+ t.equal(err, null, 'Errors should be null');
+ t.end();
+ });
+});
@@ -0,0 +1,46 @@
+/**
+ * Test suite
+ *
+ * @package troll
+ * @author Andrew Sliwinski <andrew@diy.org>
+ */
+
+/**
+ * Dependencies
+ */
+var async = require('async'),
+ test = require('tap').test,
+
+ target = require(__dirname + '/../lib/index.js');
+
+/**
+ * Suite
+ */
+async.auto({
+
+ troll: function (callback) {
+ target.troll(callback);
+ },
+
+ test: ['troll', function (callback, obj) {
+ test('Component definition', function (t) {
+ t.type(target, 'object', 'Component should be an object');
+ t.type(target.troll, 'function', 'Method should be a function');
+ t.end();
+ });
+
+ test('troll method', function (t) {
+ t.type(obj.all, 'object', 'Results should be an object');
+ t.end();
+ });
+
+ callback();
+ }]
+
+}, function (err, obj) {
+ test('Catch errors', function (t) {
+ t.equal(err, null, 'Errors should be null');
+ t.end();
+ process.exit();
+ });
+});

0 comments on commit d0cb44d

Please sign in to comment.