Skip to content

Commit

Permalink
spotter demo 260+k
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Mar 23, 2014
1 parent 833a5ec commit 0e04d24
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 32 deletions.
5 changes: 4 additions & 1 deletion build/footer.js
Expand Up @@ -12,7 +12,10 @@ var main = {
adj_to_noun: adj_to_noun,
dates: date_extractor,
tag: pos,
spot: spot,
spot: function(text, options) {
var tags = pos(text, options)
return spot(tags, options)
},
tests: tests,
}

Expand Down
47 changes: 19 additions & 28 deletions client_side/index.html
Expand Up @@ -50,19 +50,6 @@
$("#pos").find("input").keyup(function(){
var txt=$(this).val() || ''
var data= nlp.tag(txt)
console.log(data)
var colours = [
"#1f77b4", "#aec7e8",
"#ff7f0e", "#ffbb78",
"#2ca02c", "#98df8a",
"#d62728", "#ff9896",
"#9467bd", "#c5b0d5",
"#8c564b", "#c49c94",
"#e377c2", "#f7b6d2",
"#7f7f7f", "#c7c7c7",
"#bcbd22", "#dbdb8d",
"#17becf", "#9edae5"
];
var glues={
"adjective":"lightsteelblue",
"noun":"coral",
Expand All @@ -79,26 +66,30 @@
$(this).siblings(".result").html(html)
})

// $("#spot").find("input").keyup(function(){
// var txt=$(this).val() || ''
// var data= nlp.spot(txt)
// console.log(data)
// var html= data.map(function(p){
// return "<div class='word'>"+p.word+"("+p.pos.tag+") </div>"
// }).join(" ")
// $(this).siblings(".result").html(html)
// })
$("#spot").find("input").keyup(function(){
var txt=$(this).val() || ''
var data= nlp.spot(txt)
var html= data.map(function(p){
return "<div style='background:lightsteelblue; font-size:30px; display:inline-block; color:white; margin:5px; padding:8px;'>"+p.word+"</div>"
}).join(" ")
$(this).siblings(".result").html(html)
})

$("#ngram").find("input").keyup(function(){
var txt=$(this).val() || ''
var data= nlp.ngram(txt)
$(this).siblings(".result").html(JSON.stringify(data))
var html= "";
for(var i in data){
html+="<div> <b style='font-size:20px;'>"+data[i][0].word+"</b> - used "+data[i][0].count+" times</div>"
}
$(this).siblings(".result").html(html)
})

$("#sentences").find("input").keyup(function(){
var txt=$(this).val() || ''
var data= nlp.sentences(txt)
$(this).siblings(".result").html(JSON.stringify(data))
var html= data.map(function(s){return "<div style='font-size:20px; border:1px solid grey; margin:5px; display:inline-block;'>"+s+"</div>"}).join("")
$(this).siblings(".result").html(html)
})

$("#britishize").find("input").keyup(function(){
Expand Down Expand Up @@ -153,31 +144,31 @@ <h3>demo of <a href="https://github.com/spencermountain/nlp_comprimise">nlp_comp
<hr/>
<h2>PART-OF-SPEECH TAGGING!</h2>
<h3>nlp.tag(text, {})</h3>
<input type="text" value="She sells seashells by the seashore. The shells she sells are surely seashells."/>
<input type="text" value="She sells seashells by the seashore. the shells she sells are sure seashells."/>
<div class="result" style="font-size:10px;"></div>
</div>

<div id="spot">
<hr/>
<h2>NAMED-ENTITY-RECOGNITION!</h2>
<h3>nlp.spot(text, {})</h3>
<input type="text" value="She sells seashells by the seashore. The shells she sells are surely seashells."/>
<input type="text" value="joe carter went to the toronto international film festival to go see inception."/>
<div class="result" style="font-size:10px;"></div>
</div>

<div id="ngram">
<hr/>
<h2>N-gram!</h2>
<h3>nlp.ngram(text, {})</h3>
<input type="text" value="She sells seashells by the seashore. The shells she sells are surely seashells."/>
<input type="text" value="She sells seashells by the seashore. the shells she sells are sure seashells."/>
<div class="result" style="font-size:10px;"></div>
</div>

<div id="sentences">
<hr/>
<h2>Sentences!</h2>
<h3>nlp.sentences(text)</h3>
<input type="text" value="She sells seashells by the seashore. The shells she sells are surely seashells."/>
<input type="text" value="She sells seashells by the seashore. the shells she sells are sure seashells."/>
<div class="result" style="font-size:14px;"></div>
</div>

Expand Down
5 changes: 4 additions & 1 deletion client_side/nlp.js
Expand Up @@ -21484,7 +21484,10 @@ var main = {
adj_to_noun: adj_to_noun,
dates: date_extractor,
tag: pos,
spot: spot,
spot: function(text, options) {
var tags = pos(text, options)
return spot(tags, options)
},
tests: tests,
}

Expand Down
2 changes: 1 addition & 1 deletion client_side/nlp.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"author": "Spencer Kelly <spencerwater@gmail.com> (http://spencerwaterbed.com)",
"name": "nlp_comprimise",
"description": "natural language processing in javascript, in the browser",
"version": "0.0.5",
"version": "0.0.6",
"repository": {
"type": "git",
"url": "git://github.com/spencermountain/nlp-node.git"
Expand Down

0 comments on commit 0e04d24

Please sign in to comment.