Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristiSodano committed Jun 5, 2012
2 parents c71329c + 08dca4d commit 672231d
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 17 deletions.
4 changes: 2 additions & 2 deletions ajax/getParaNLP.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require('../lib/simple_html_dom.php');
$oc = new OpenCalais('t7vydt6bxg5m6v2vtc7bk929');
$html = file_get_html($_GET['url']);
$threshold = 0.4;
$threshold = 0.5;
//$html = file_get_contents('http://www.forbes.com/sites/petercohan/2012/04/12/9-99-e-book-price-to-cost-apple-252-million/');

//$extractor = new ContentExtractor();
Expand All @@ -20,7 +20,7 @@
$largestLength = strlen($html->find('p',$i)->innertext);
}
}
$entities = $oc->getEntities($html->find('p',$largestIndex)->innertext);
$entities = $oc->getEntities($html->find('p',1)->innertext);

?>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion ajax/getTitleNLP.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require('../lib/simple_html_dom.php');
$oc = new OpenCalais('t7vydt6bxg5m6v2vtc7bk929');
$html = file_get_html($_GET['url']);
$threshold = 0.4;
$threshold = 0.5;
//$html = file_get_contents('http://www.forbes.com/sites/petercohan/2012/04/12/9-99-e-book-price-to-cost-apple-252-million/');

//$extractor = new ContentExtractor();
Expand Down
1 change: 1 addition & 0 deletions ajax/nlp.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
data-count="<?php echo $i['count'];?>"
/>
<?php echo $i['name']; ?>
<?php echo ' ('.$i['relevancy'].')';?>
</li>
<?php endforeach; ?>
</ul>
Expand Down
31 changes: 31 additions & 0 deletions ajax/nlptext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
require('../lib/opencalais.php');
require('../lib/content-extract.php');
$oc = new OpenCalais('t7vydt6bxg5m6v2vtc7bk929');
$content = $_GET['content'];
$threshold = 0.5;

$entities = $oc->getEntities($content);

?>
<ul>
<?php foreach ($entities as $key => $value): ?>
<li><?php echo ucfirst(strtolower($key));?>
<ul>
<?php foreach ($value as $i):?>
<li>
<input type="checkbox"
<?php echo ($i['relevancy']>=$threshold) ? 'checked="checked"' : "" ; ?>
data-content="<?php echo $i['name'];?>"
data-relevancy="<?php echo $i['relevancy'];?>"
data-count="<?php echo $i['count'];?>"
/>
<?php echo $i['name']; ?>
</li>
<?php endforeach; ?>
</ul>
</li>
<?php //echo $key; echo '<br/>'; echo $value; echo '<br/>';?>

<?php endforeach;?>
</ul>
1 change: 0 additions & 1 deletion ajax/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
?>
<!-- </pre> -->

<h1>Results for <?php echo $args['q'];?></h1>
<p>Based on <?php echo $args['rpp']*$pages; ?> recent tweets</p>
<div class="row">
<div class="span3">
Expand Down
Binary file added img/subtract.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@

include_once 'lib/auth.php';



$alphaKey = "a8e2eaebf76d2ecd4dabef2ff136fc87";
$threshold = 0.5;

$page = (isset($_GET['p'])) ? $_GET['p'] : 'home';
$pw = (isset($_GET['pw'])) ? $_GET['pw'] : '' ;

$root = '/tweetsweep';
$root = '/';
$navigation[] = array('page' => 'home', 'href' => $root, 'caption' => 'Home');
$navigation[] = array('page' => 'about', 'href' => $root.'?p=about', 'caption' => 'About');
$navigation[] = array('page' => 'features', 'href' => $root.'?p=features', 'caption' => 'Features');
Expand Down
2 changes: 1 addition & 1 deletion js/flot-tweetsweep.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $().ready(function(){

function plotTime(i){
d = [];
var dataurl = '/tweetsweep/ajax/times.php';
var dataurl = '/ajax/times.php';

$.getJSON(
dataurl,
Expand Down
44 changes: 38 additions & 6 deletions js/tweetsweep.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,33 @@ $(document).ready(function() {
$('#tweet-btn').addClass('disabled');
};
});


$('#composition-textarea').blur(function(){
if($('#analyze-type .active').val()!=2) return;
var ajax_load = '<img src="img/ajax-loader.gif"/>';
var content = $(this).val();
var loadUrl = 'ajax/nlptext.php';
var content = $('#composition-textarea').val();
$("#tags").html(ajax_load).load(loadUrl, "content="+content, function(){
$('#query-input').val("");
checkboxTree();
$('#query-box').show("fast");
});
});

//execute tweet on click of tweet button
$('#tweet-btn').click(function() {
var status = $('#composition-textarea').val();
var link = $('.link-input').val();

var statusToPost = status + ' ' + link;

$.post(
'ajax/tweet.php',
{ status: status },
{ status: statusToPost },
function() {
$('#composition-textarea').val('');
$('.link-input').val('');
$.doTimeout(2000, function(){
updateUserTimeline();
});
Expand All @@ -86,7 +102,11 @@ $(document).ready(function() {
var loadUrl;
if($('#analyze-type .active').val()==1){
loadUrl = 'ajax/getTitleNLP.php';
} else {
} else if($('#analyze-type .active').val()==2)
{
return;
}
else {
loadUrl = 'ajax/nlp.php';
}
$("#tags").html(ajax_load).load(loadUrl, "url="+url, function(){
Expand All @@ -103,7 +123,18 @@ $(document).ready(function() {
var loadUrl;
if($(this).val()=="1"){
loadUrl = 'ajax/getTitleNLP.php';
} else {
} else if($(this).val()=="2")
{
loadUrl = 'ajax/nlptext.php';
var content = $('#composition-textarea').val();
$("#tags").html(ajax_load).load(loadUrl, "content="+content, function(){
$('#query-input').val("");
checkboxTree();
$('#query-box').show("fast");
});
return;
}
else {
loadUrl = 'ajax/nlp.php';
}
$("#tags").html(ajax_load).load(loadUrl, "url="+url, function(){
Expand Down Expand Up @@ -140,7 +171,7 @@ $( "#slider" ).slider({
range:"min",
value:500,
min: 100,
max: 2000,
max: 1500,
step: 100,
slide: function( event, ui ) {
$( "#amount" ).val( ui.value );
Expand Down Expand Up @@ -290,7 +321,8 @@ function checkboxTree(){
string = string.replace(new RegExp($(this).data("content"),"i"),$(this).data("content"));
$('#query-input').val(string);
} else{
string += " "+$(this).data("content");
if ($('#query-input').val() != ""){ string += ' OR'};
string += ' "'+$(this).data("content")+'"';
$('#query-input').val(string);
}
}
Expand Down
13 changes: 9 additions & 4 deletions templates/components/dashboard_nav.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
<li class="{{active}}"><a href="{{ item.href }}">{{ item.caption }}</a></li>
{% set active = '' %}
{% endfor %}
<!-- <li class="divider-vertical"></li>
<li><a href="#">Recon</a></li>
<li><a href="#">Reach</a></li>
<li><a href="#">Reflection</a></li> -->
<li class="divider-vertical"></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Feedback <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="https://docs.google.com/spreadsheet/viewform?formkey=dFotaVZqaG5odEROeUUwMWhaZlBMY0E6MQ#gid=0" target="_blank">Report a Bug</a></li>
<li><a href="https://docs.google.com/spreadsheet/viewform?formkey=dGhaQnhKVm5SRTgwSWhveXhrZFhtMVE6MQ#gid=0" target="_blank">Take the Survey</a></li>
</ul>
</li>


</ul>

Expand Down
17 changes: 16 additions & 1 deletion templates/dashboard.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@

<div id="slider" style="margin-bottom:10px"></div>
<!-- <hr/> -->
<h5 style="float:left;margin-right:20px;padding:4px 0px 0px 4px;">Analyze:</h5>
<h5 style="margin-right:20px;padding:4px 0px 0px 4px;">Analyze:</h5>
<div id="analyze-type" class="btn-group" name="analyze-type" data-toggle="buttons-radio">
<button class="btn active" value="0">All Content</button>
<button class="btn" value="1">Headline Only</button>
<button class="btn" value="2">Tweet</button>
</div>

</div><!-- End demo -->
Expand Down Expand Up @@ -186,6 +187,20 @@
var options = {'title': 'Sample Size Control', 'content': 'A higher sample size results in more accurate results, but takes longer to compute. A lower sample size computes results much faster but at the cost of accuracy.'};
$('#sampleSizeHelp').popover(options);
</script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-32109497-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>



Expand Down
14 changes: 14 additions & 0 deletions templates/home.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<script src="js/bootstrap.js"></script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-32109497-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>



</body>
Expand Down

0 comments on commit 672231d

Please sign in to comment.