Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Extract names from text
<textarea id="tu" cols="90" rows="10">Your text goes here </textarea>
<input id="btget" class="mybutton" type="button" value="Go Extract Info"/>
<div id="imgdiv" ></div>
function init(){
var contentanalysisURL="*%20from%20contentanalysis.analyze%20where%20text%3D%22{text}%22&format=json&callback=?";
//this function will be called on json recieve
function receiveJSON(data){
//6. recieve Data
//7.get list of all entities
var et=data.query.results.entities.entity;
var out=[];
var len=et.length;
for(var i=0;i<len;i++){
var eee=et[i];
//8.get entity name
var content=eee.text.content;
var startChar=eee.text.start;
var etypes="";
//9.get entity type
var typ=eee.types.type;
for(var j=0;j<typ.length;j++){
var ttt=typ[j].content;
etypes=etypes+" "+ ttt.substring(ttt.lastIndexOf('/')+1);
//10.Append to dumo array
//11.update container with output
//1. hook click event of btget
$('#btget').click(function (){
//2. Get text, length of text should be less than 512 or less.
//Note:when text is too large this will not work
var text=$('#tu').val();
//3.Update login mesage
//4.Form a GET request, (YQL table )
var url=contentanalysisURL.replace("{text}",text);
//5. inject script block in dom with callback as receiveJSON
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.