Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 49088419a9f835c5e9b3d0e0e438740ba23eb0db @brendannee committed Mar 9, 2012
@@ -0,0 +1,2 @@
+options.js
+node_modules
@@ -0,0 +1,17 @@
+#Naive Baysian Tweet Classifier in Node.js
+
+Classify tweets using Node.js and a [naive Bayesian classifier](http://en.wikipedia.org/wiki/Naive_Bayes_classifier).
+
+Tweets are pulled from the [twitter streaming api](https://dev.twitter.com/docs/streaming-api/methods) and queued to be classified. After classifying a bunch of tweets into Spam, Interesting, Not English, or Not-interesting it will attempt to predict which of these categories a tweet fits into.
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2012 Brendan Nee <me@bn.ee>
+
+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.
15 boot.js
@@ -0,0 +1,15 @@
+var config = require('./config')
+ , routes = require('./routes')
+ , tweets = require('./tweets');
+
+module.exports = function boot(app){
+
+ config(app);
+
+ routes(app);
+
+ tweets(app);
+
+ return app;
+
+}
@@ -0,0 +1,44 @@
+try{
+ var options = require('./options.js');
+} catch(e) {
+ console.log('Can\'t load options.js with twitter auth keys');
+}
+
+var express = require('express')
+ , mongoose = require('mongoose')
+ , dbName = process.env['MONGO_NODE_DATABASE'] || options.mongo_node_database
+ , host = process.env['MONGO_NODE_HOST'] || options.mongo_node_host
+ , port = process.env['MONGO_NODE_PORT'] || options.mongo_node_port
+ , db = (port) ? mongoose.connect(host, dbName, port) : mongoose.connect(host, dbName);
+
+module.exports = function(app){
+ app.configure(function(){
+ this.use(express.cookieParser())
+ .use(express.bodyParser())
+ .set('public', __dirname + '/public')
+ .enable('jsonp callback')
+ .enable('error templates')
+ .use(express.static(__dirname + '/public'))
+ .set('db', db)
+ .set('options', options)
+ });
+
+ // Dev
+ app.configure('development', function(){
+ this.use(express.profiler())
+ .use(express.logger('\x1b[90m:remote-addr -\x1b[0m \x1b[33m:method\x1b[0m' +
+ '\x1b[32m:url\x1b[0m :status \x1b[90m:response-time ms\x1b[0m'))
+ .use(express.errorHandler({dumpExceptions: true, showStack: true}))
+ .enable('dev')
+ .set('domain', 'app.local');
+ });
+
+ // Prod
+ app.configure('production', function(){
+ this
+ .use(express.logger({buffer: 10000}))
+ .use(express.errorHandler())
+ .enable('prod')
+ .set('domain', 'productiondomain.com');
+ });
+}
@@ -0,0 +1,14 @@
+
+var boot = module.exports = require('./boot')
+ , app = require('express').createServer();
+
+module.exports = boot(app);
+
+if (!module.parent) {
+ var port = process.env.PORT || 8081;
+ app.listen(port, function(){
+ console.error('\x1b[32m' + app.set('domain') + '\x1b[0m running on port %d',
+ app.address().port);
+ });
+
+}
@@ -0,0 +1,11 @@
+var mongoose = require('mongoose');
+
+var Tweet = mongoose.model('Tweet', new mongoose.Schema({
+ id_str : { type: String, unique: true }
+ , text : { type: String }
+ , created_at : { type: String }
+ , spam : { type: Boolean }
+ , interesting : { type: Boolean }
+ , non_english : { type: Boolean }
+ , classified : { type: Boolean, default: false }
+ }));
@@ -0,0 +1,16 @@
+{
+ "name": "naive-baysian-twitter",
+ "description": "",
+ "version": "0.0.0",
+ "author": "Brendan Nee <me@bn.ee>",
+ "dependencies": {
+ "express": ">= 2.5.8"
+ , "mongoose": ">= 2.5.7"
+ , "async": ">= 0.1.16"
+ , "request": ">= 2.9.152"
+ , "underscore": ">= 1.3.1"
+ , "ntwitter": ">=0.2.10"
+ , "socket.io": ">=0.9.1-1"
+ },
+ "main": "index"
+}
Oops, something went wrong.

0 comments on commit 4908841

Please sign in to comment.