Commits

Aaron Zinman committed d81ca60 Draft

-capitalization, its not working

Comments (0)

Files changed (3)

frontend/js/defuse.production-20120704.js

             { desc:"write at a high school level", desc_singluar:"writes at a high school level", authorKeys:[] },
             { desc:"write at a college level", desc_singluar:"writes at a college level level", authorKeys:[] },
             { desc:"write at a graduate school level", desc_singluar:"writes at a graduate school level", authorKeys:[] } ]
-        },
+        },/*
         { desc: "capitalization",
           key: "capitalization",
           type: "percentage_community_normalized_bucket",
             { desc:"sometimes capitalizes", desc_singluar:"sometimes capitalizes", authorKeys:[] },
             { desc:"usually capitalizes", desc_singluar:"usually capitalizes", authorKeys:[] },
             { desc:"always capitalizes", desc_singluar:"always capitalizes", authorKeys:[] } ]
-        },
+        },*/
         { desc: "sentiment analysis",
           key: "sentiment",
           type: "threshold_classify",

frontend/js/defuse.production-20120704.min.js

 filter.buckets[bucketIdx].authorKeys.push(authorKey);});}else if(filter.type=="classify"){console.log("Got back "+count+" classification results for "+filter.desc);_.each(results,function(cls,authorKey){cls=cls.toLowerCase();var bucketIdx=-1;for(var i=0;i<filter.buckets.length;i++){var bucket=filter.buckets[i];if(bucket.type=="unknown")bucketIdx=i;if(bucket.key==cls){bucketIdx=i;break;}}
 filter.buckets[bucketIdx].authorKeys.push(authorKey);});}else if(filter.type=="threshold_classify"){console.log("Got back "+count+" threshold classification results for "+filter.desc);if(!filter.thresholds||filter.thresholds.length!=filter.buckets.length-1){throw"Invalid filter thresholds";}
 _.each(results,function(score,authorKey){score=parseFloat(score);var bucketIdx=score<filter.thresholds[0]?0:(score<filter.thresholds[1]?1:(filter.thresholds.length==2?2:(score<filter.thresholds[2]?2:3)));filter.buckets[bucketIdx].authorKeys.push(authorKey);});}else{console.log(["Don't recognize filter type: ",filter.type,"from filter",filter]);return;}
-var totalCount=0;_.each(filter.buckets,function(bucket){totalCount+=bucket.authorKeys.length;});_.each(filter.buckets,function(bucket){bucket.percentage=Math.round(bucket.authorKeys.length*100.0/totalCount);bucket.percentageFloat=bucket.authorKeys.length*100.0/totalCount;});},randomTestData:function(filter){if(filter.buckets!=null){var cache=defuse.model.cache;var total=cache.numComments;var bucketCounts=_.map(filter.buckets,function(bucket){var thisBucket=Math.floor(Math.random()*total);bucket.fakeCount=thisBucket;total-=thisBucket;return thisBucket;});var spareAuthors=_.pluck(cache.authorGestalts,"authorKey");_.each(filter.buckets,function(bucket){for(var i=0;i<bucket.fakeCount;i++){bucket.authorKeys.push(spareAuthors.pop());}});}},getCategory:function(categoryName){return _.detect(defuse.model.filters.categories,function(category){return category.name.toLowerCase()==categoryName.toLowerCase();});},categories:[{name:"Social",adverb:"Socially",color:"#3FA9F5",colorName:"blue",questions:"How do the commenters interact with others? Are they good community members?",filters:[{desc:"contribution",key:"contribution",type:"absolute_community_normalized_bucket",exploreMoreQuestion:"How often do these people comment?",buckets:[{desc:"rarely comment",desc_singluar:"rarely comments",threshold:10,authorKeys:[]},{desc:"sometimes comment",desc_singluar:"sometimes comments",threshold:100,authorKeys:[]},{desc:"frequently comment",desc_singluar:"frequently comments",threshold:-1,authorKeys:[]}]},{desc:"reactions vs replies",key:"reactionsvsreplies",type:"percentage_community_normalized_bucket",exploreMoreQuestion:"What percentage of their comments are replies to others?",buckets:[{desc:"never reply to others",desc_singluar:"never replies to others",authorKeys:[]},{desc:"rarely reply to others",desc_singluar:"rarely replies to others",authorKeys:[]},{desc:"often reply to others",desc_singluar:"often replies to others",authorKeys:[]},{desc:"heavily reply to others",desc_singluar:"heavily replies to others",authorKeys:[]}]},{desc:"community response",key:"recommendations",type:"absolute_community_normalized_bucket",verb:"are",verb_singular:"is",exploreMoreQuestion:"How frequently do these people get their comments recommended?",buckets:[{desc:"never recommened by others",desc_singular:"never recommended by others",threshold:1,authorKeys:[]},{desc:"rarely recommended by others",desc_singular:"rarely recommended by others",threshold:10,authorKeys:[]},{desc:"often recommended by others",desc_singular:"often recommended by others",threshold:50,authorKeys:[]},{desc:"usually recommended by others",desc_singular:"usually recommended by others",threshold:-1,authorKeys:[]}]}]},{name:"Political",adverb:"Politically",color:"#7AC943",colorName:"green",questions:"What are the political viewpoints and concerns of the commenters?",filters:[{desc:"political affiliation",key:"political",type:"weighted_classify",verb:"are",verb_singular:"is",exploreMoreQuestion:"Are these people more republican, democrats, or other/unknown?",buckets:[{desc:"democrats",desc_singluar:"democrat",type:"democrat",key:"democrat",authorKeys:[]},{desc:"republicans",desc_singluar:"republican",key:"republican",authorKeys:[]},{desc:"not grouped",type:"unknown",key:"unknown",desc_singluar:"wasn't grouped",authorKeys:[]}]}]},{name:"Cultural",adverb:"Culturally",color:"#FF931E",colorName:"orange",questions:"Where do they fit within society? What are their influences? What topics concern them?",filters:[{desc:"geography",key:"geography",type:"classify",exploreMoreQuestion:"Where are these people from?",buckets:[{desc:"are from western us",desc_singluar:"is from western us",key:"us_west",authorKeys:[]},{desc:"are from central us",desc_singluar:"is from central us",key:"us_central",authorKeys:[]},{desc:"are from eastern us",desc_singluar:"is from eastern us",key:"us_east",authorKeys:[]},{desc:"are from outside the us",desc_singluar:"is from outside the us",type:"world",authorKeys:[]},{desc:"not grouped",desc_singluar:"wasn't grouped",key:"Unknown",type:"unknown",authorKeys:[]}]},{desc:"acronyms",key:"acronyms",type:"percentage_community_normalized_bucket",exploreMoreQuestion:"How frequently do these people use acronyms in their comments?",buckets:[{desc:"never use acronyms",desc_singluar:"never uses acronyms",authorKeys:[]},{desc:"rarely use acronyms",desc_singluar:"rarely uses acronyms",authorKeys:[]},{desc:"often use acronyms",desc_singluar:"often uses acronyms",authorKeys:[]},{desc:"heavily use acronyms",desc_singluar:"heavily uses acronyms",authorKeys:[]}]}]},{name:"Linguistic",adverb:"Linguistically",color:"#FF1D25",colorName:"red",questions:"How do they speak? What tone of voice do they use?",filters:[{desc:"readability",key:"readability",type:"threshold_classify",thresholds:[5,8,12,16],exploreMoreQuestion:"What are these people's average "+'<a href="http://en.wikipedia.org/wiki/Flesch–Kincaid_readability_test">Flesch-Kincaid</a> '+'and <a href="http://en.wikipedia.org/wiki/Gunning_fog_index">Gunning fog</a> '+"readability scores?",buckets:[{desc:"write at an elementary school level",desc_singluar:"writes at an elementary school level",authorKeys:[]},{desc:"write at a middle school level",desc_singluar:"writes at a middle school level",authorKeys:[]},{desc:"write at a high school level",desc_singluar:"writes at a high school level",authorKeys:[]},{desc:"write at a college level",desc_singluar:"writes at a college level level",authorKeys:[]},{desc:"write at a graduate school level",desc_singluar:"writes at a graduate school level",authorKeys:[]}]},{desc:"capitalization",key:"capitalization",type:"percentage_community_normalized_bucket",exploreMoreQuestion:"How often do these people capitalize?",buckets:[{desc:"rarely capitalizes",desc_singluar:"rarely capitalizes",authorKeys:[]},{desc:"sometimes capitalizes",desc_singluar:"sometimes capitalizes",authorKeys:[]},{desc:"usually capitalizes",desc_singluar:"usually capitalizes",authorKeys:[]},{desc:"always capitalizes",desc_singluar:"always capitalizes",authorKeys:[]}]},{desc:"sentiment analysis",key:"sentiment",type:"threshold_classify",thresholds:[0.33,0.66],exploreMoreQuestion:"How do these people write on average, according to "+'<a href="http://en.wikipedia.org/wiki/Sentiment_analysis">sentiment analysis</a>?',buckets:[{desc:"are usually negative",desc_singluar:"is usually negative",authorKeys:[]},{desc:"are neutral",desc_singluar:"is neutral",authorKeys:[]},{desc:"are usually positive",desc_singluar:"is usually positive",authorKeys:[]}]}]}]};defuse.model.emptyCache=function(){console.log("Emptying cache");defuse.model.cache={authorGestaltByKey:{},commentCollectionObj:null,numComments:0,leftoverAuthorKeys:[]};_.each(defuse.model.filters.categories,function(filter){_.each(filter.filters,function(filter){delete filter["loaded"];if(filter.buckets!=null){_.each(filter.buckets,function(bucket){delete bucket["authorKeys"];bucket.authorKeys=[];});}});});return defuse.model.cache;};defuse.model.emptyCache();defuse.services.backend=(function(){if(window.location.protocol=="file:"){var serverUrl="http://localhost:10000";}else{var serverUrl="http://defuse.media.mit.edu";}
+var totalCount=0;_.each(filter.buckets,function(bucket){totalCount+=bucket.authorKeys.length;});_.each(filter.buckets,function(bucket){bucket.percentage=Math.round(bucket.authorKeys.length*100.0/totalCount);bucket.percentageFloat=bucket.authorKeys.length*100.0/totalCount;});},randomTestData:function(filter){if(filter.buckets!=null){var cache=defuse.model.cache;var total=cache.numComments;var bucketCounts=_.map(filter.buckets,function(bucket){var thisBucket=Math.floor(Math.random()*total);bucket.fakeCount=thisBucket;total-=thisBucket;return thisBucket;});var spareAuthors=_.pluck(cache.authorGestalts,"authorKey");_.each(filter.buckets,function(bucket){for(var i=0;i<bucket.fakeCount;i++){bucket.authorKeys.push(spareAuthors.pop());}});}},getCategory:function(categoryName){return _.detect(defuse.model.filters.categories,function(category){return category.name.toLowerCase()==categoryName.toLowerCase();});},categories:[{name:"Social",adverb:"Socially",color:"#3FA9F5",colorName:"blue",questions:"How do the commenters interact with others? Are they good community members?",filters:[{desc:"contribution",key:"contribution",type:"absolute_community_normalized_bucket",exploreMoreQuestion:"How often do these people comment?",buckets:[{desc:"rarely comment",desc_singluar:"rarely comments",threshold:10,authorKeys:[]},{desc:"sometimes comment",desc_singluar:"sometimes comments",threshold:100,authorKeys:[]},{desc:"frequently comment",desc_singluar:"frequently comments",threshold:-1,authorKeys:[]}]},{desc:"reactions vs replies",key:"reactionsvsreplies",type:"percentage_community_normalized_bucket",exploreMoreQuestion:"What percentage of their comments are replies to others?",buckets:[{desc:"never reply to others",desc_singluar:"never replies to others",authorKeys:[]},{desc:"rarely reply to others",desc_singluar:"rarely replies to others",authorKeys:[]},{desc:"often reply to others",desc_singluar:"often replies to others",authorKeys:[]},{desc:"heavily reply to others",desc_singluar:"heavily replies to others",authorKeys:[]}]},{desc:"community response",key:"recommendations",type:"absolute_community_normalized_bucket",verb:"are",verb_singular:"is",exploreMoreQuestion:"How frequently do these people get their comments recommended?",buckets:[{desc:"never recommened by others",desc_singular:"never recommended by others",threshold:1,authorKeys:[]},{desc:"rarely recommended by others",desc_singular:"rarely recommended by others",threshold:10,authorKeys:[]},{desc:"often recommended by others",desc_singular:"often recommended by others",threshold:50,authorKeys:[]},{desc:"usually recommended by others",desc_singular:"usually recommended by others",threshold:-1,authorKeys:[]}]}]},{name:"Political",adverb:"Politically",color:"#7AC943",colorName:"green",questions:"What are the political viewpoints and concerns of the commenters?",filters:[{desc:"political affiliation",key:"political",type:"weighted_classify",verb:"are",verb_singular:"is",exploreMoreQuestion:"Are these people more republican, democrats, or other/unknown?",buckets:[{desc:"democrats",desc_singluar:"democrat",type:"democrat",key:"democrat",authorKeys:[]},{desc:"republicans",desc_singluar:"republican",key:"republican",authorKeys:[]},{desc:"not grouped",type:"unknown",key:"unknown",desc_singluar:"wasn't grouped",authorKeys:[]}]}]},{name:"Cultural",adverb:"Culturally",color:"#FF931E",colorName:"orange",questions:"Where do they fit within society? What are their influences? What topics concern them?",filters:[{desc:"geography",key:"geography",type:"classify",exploreMoreQuestion:"Where are these people from?",buckets:[{desc:"are from western us",desc_singluar:"is from western us",key:"us_west",authorKeys:[]},{desc:"are from central us",desc_singluar:"is from central us",key:"us_central",authorKeys:[]},{desc:"are from eastern us",desc_singluar:"is from eastern us",key:"us_east",authorKeys:[]},{desc:"are from outside the us",desc_singluar:"is from outside the us",type:"world",authorKeys:[]},{desc:"not grouped",desc_singluar:"wasn't grouped",key:"Unknown",type:"unknown",authorKeys:[]}]},{desc:"acronyms",key:"acronyms",type:"percentage_community_normalized_bucket",exploreMoreQuestion:"How frequently do these people use acronyms in their comments?",buckets:[{desc:"never use acronyms",desc_singluar:"never uses acronyms",authorKeys:[]},{desc:"rarely use acronyms",desc_singluar:"rarely uses acronyms",authorKeys:[]},{desc:"often use acronyms",desc_singluar:"often uses acronyms",authorKeys:[]},{desc:"heavily use acronyms",desc_singluar:"heavily uses acronyms",authorKeys:[]}]}]},{name:"Linguistic",adverb:"Linguistically",color:"#FF1D25",colorName:"red",questions:"How do they speak? What tone of voice do they use?",filters:[{desc:"readability",key:"readability",type:"threshold_classify",thresholds:[5,8,12,16],exploreMoreQuestion:"What are these people's average "+'<a href="http://en.wikipedia.org/wiki/Flesch–Kincaid_readability_test">Flesch-Kincaid</a> '+'and <a href="http://en.wikipedia.org/wiki/Gunning_fog_index">Gunning fog</a> '+"readability scores?",buckets:[{desc:"write at an elementary school level",desc_singluar:"writes at an elementary school level",authorKeys:[]},{desc:"write at a middle school level",desc_singluar:"writes at a middle school level",authorKeys:[]},{desc:"write at a high school level",desc_singluar:"writes at a high school level",authorKeys:[]},{desc:"write at a college level",desc_singluar:"writes at a college level level",authorKeys:[]},{desc:"write at a graduate school level",desc_singluar:"writes at a graduate school level",authorKeys:[]}]},{desc:"sentiment analysis",key:"sentiment",type:"threshold_classify",thresholds:[0.33,0.66],exploreMoreQuestion:"How do these people write on average, according to "+'<a href="http://en.wikipedia.org/wiki/Sentiment_analysis">sentiment analysis</a>?',buckets:[{desc:"are usually negative",desc_singluar:"is usually negative",authorKeys:[]},{desc:"are neutral",desc_singluar:"is neutral",authorKeys:[]},{desc:"are usually positive",desc_singluar:"is usually positive",authorKeys:[]}]}]}]};defuse.model.emptyCache=function(){console.log("Emptying cache");defuse.model.cache={authorGestaltByKey:{},commentCollectionObj:null,numComments:0,leftoverAuthorKeys:[]};_.each(defuse.model.filters.categories,function(filter){_.each(filter.filters,function(filter){delete filter["loaded"];if(filter.buckets!=null){_.each(filter.buckets,function(bucket){delete bucket["authorKeys"];bucket.authorKeys=[];});}});});return defuse.model.cache;};defuse.model.emptyCache();defuse.services.backend=(function(){if(window.location.protocol=="file:"){var serverUrl="http://localhost:10000";}else{var serverUrl="http://defuse.media.mit.edu";}
 console.log("server url: "+serverUrl);$.ajaxSetup({dataType:"json",timeout:1000*120});var pendingNetworkReqs={};var backend={jsonWorker:(function(){var worker=new Worker("js/defuse/services/jsonWorker.js");worker.onmessage=function(ev){var e=ev.data;var pendingReq=pendingNetworkReqs[e.reqId];if(pendingReq==null){throw"Could not find pending request id "+e.reqId;}
 pendingNetworkReqs[e.reqId]=undefined;pendingReq.timer();if(e.type=="success"){pendingReq.success(e.jsonData);}else{pendingReq.error(null,"Error parsing JSON: "+origStr,e.e);}};return worker;})(),rerouteJson:function(){console.log("Rerouting ajax deserialization to web worker");var $ajax=$.ajax;$.ajax=function(req){req.dataType="text";var origSuccess=req.success;req.success=function(jsonStr,status,xhr){req.success=function(jsonData){origSuccess(jsonData,status,xhr);};var reqId=_.uniqueId("req");pendingNetworkReqs[reqId]=req;req.timer=defuse.timer.loggingSimpleTimer("Web worker parsing of "+jsonStr.length+" bytes of JSON");defuse.services.backend.jsonWorker.postMessage({reqId:reqId,jsonStr:jsonStr});};$ajax(req);};},nytimes:{getLatestCommentedCollections:function(callback){var timer=defuse.timer.loggingSimpleTimer("/api/nytimes/latestCommentedCollections");try{$.ajax({dataType:"json",url:serverUrl+"/api/nytimes/latestCommentedCollections",timeout:1000*20,success:function(data,status,xhr){timer();callback(data);console.log("done with ajax success");},error:function(xhr,textStatus,errorThrown){console.log("FAILED Ajax: "+textStatus);},cache:false});}catch(e){log.warn("Could not get latest commented collections: ");log.warn(e);}},getDaysCollections:function(day,callback){var timer=defuse.timer.loggingSimpleTimer("/api/nytimes/daysCollections");try{$.ajax({dataType:"json",data:{day:day},url:serverUrl+"/api/nytimes/daysCollections",timeout:1000*20,success:function(data,status,xhr){timer();callback(data);console.log("done with ajax success");},error:function(xhr,textStatus,errorThrown){console.log("FAILED Ajax: "+textStatus);},cache:false});}catch(e){log.warn("Could not get latest commented collections: ");log.warn(e);}},loadAuthorGestalts:function(authorKeys,callback){var timer=defuse.timer.loggingSimpleTimer("/api/authorGestalts ("+authorKeys.length+" authors)");var cache=defuse.model.cache;var toRetrieve=$.map(authorKeys,function(key){if(cache.authorGestaltByKey==null||cache.authorGestaltByKey[key]==null){return key;}
 return null;});if(toRetrieve.length==0){callback();return;}

frontend/js/defuse/model/filters.js

             { desc:"write at a high school level", desc_singluar:"writes at a high school level", authorKeys:[] },
             { desc:"write at a college level", desc_singluar:"writes at a college level level", authorKeys:[] },
             { desc:"write at a graduate school level", desc_singluar:"writes at a graduate school level", authorKeys:[] } ]
-        },
+        },/*
         { desc: "capitalization",
           key: "capitalization",
           type: "percentage_community_normalized_bucket",
             { desc:"sometimes capitalizes", desc_singluar:"sometimes capitalizes", authorKeys:[] },
             { desc:"usually capitalizes", desc_singluar:"usually capitalizes", authorKeys:[] },
             { desc:"always capitalizes", desc_singluar:"always capitalizes", authorKeys:[] } ]
-        },
+        },*/
         { desc: "sentiment analysis",
           key: "sentiment",
           type: "threshold_classify",