Modified: 
incubator/stanbol/trunk/demos/webvie/src/main/resources/org/apache/stanbol/commons/web/vie/static/lib/vie/vie-latest.js
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/demos/webvie/src/main/resources/org/apache/stanbol/commons/web/vie/static/lib/vie/vie-latest.js?rev=1297389&r1=1297388&r2=1297389&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/demos/webvie/src/main/resources/org/apache/stanbol/commons/web/vie/static/lib/vie/vie-latest.js
 (original)
+++ 
incubator/stanbol/trunk/demos/webvie/src/main/resources/org/apache/stanbol/commons/web/vie/static/lib/vie/vie-latest.js
 Tue Mar  6 08:56:24 2012
@@ -1 +1 @@
-/*VIE may be freely distributed under the MIT license.*/(function(){var 
a=this,d=a.jQuery,e=a.Backbone,b=a._;var 
c=a.VIE=function(f){this.config=(f)?f:{};this.services={};this.jQuery=d;this.entities=new
 
this.Collection();this.Entity.prototype.entities=this.entities;this.entities.vie=this;this.Entity.prototype.entityCollection=this.Collection;this.Entity.prototype.vie=this;this.Namespaces.prototype.vie=this;this.namespaces=new
 
this.Namespaces((this.config.baseNamespace)?this.config.baseNamespace:"http://viejs.org/ns/",{owl:"http://www.w3.org/2002/07/owl#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",schema:"http://schema.org/",foaf:"http://xmlns.com/foaf/0.1/",geo:"http://www.w3.org/2003/01/geo/wgs84_pos#",dbpedia:"http://dbpedia.org/ontology/",dbprop:"http://dbpedia.org/property/",skos:"http://www.w3.org/2004/02/skos/core#",xsd:"http://www.w3.org/2001/XMLSchema#",sioc:"http://rdfs.org/sioc/ns#",dcterms:"http://purl.org/dc/ter
 
ms/"});this.Type.prototype.vie=this;this.Types.prototype.vie=this;this.Attribute.prototype.vie=this;this.Attributes.prototype.vie=this;this.types=new
 
this.Types();this.types.add("owl:Thing");if(this.config.classic!==false){this.RDFa=new
 this.ClassicRDFa(this);this.RDFaEntities=new 
this.ClassicRDFaEntities(this);this.EntityManager=new 
this.ClassicEntityManager(this);this.cleanup=function(){this.entities.reset()}}};c.prototype.use=function(f,g){if(!g&&!f.name){throw
 new Error("Please provide a name for the 
service!")}f.vie=this;f.name=(g)?g:f.name;if(f.init){f.init()}this.services[f.name]=f;return
 this};c.prototype.service=function(f){if(!this.services[f]){throw"Undefined 
service "+f}return 
this.services[f]};c.prototype.getServicesArray=function(){return 
b.map(this.services,function(f){return 
f})};c.prototype.load=function(f){if(!f){f={}}f.vie=this;return new 
this.Loadable(f)};c.prototype.save=function(f){if(!f){f={}}f.vie=this;return 
new this.Savable(f)};c.prototype.remove=fu
 nction(f){if(!f){f={}}f.vie=this;return new 
this.Removable(f)};c.prototype.analyze=function(f){if(!f){f={}}f.vie=this;return
 new 
this.Analyzable(f)};c.prototype.find=function(f){if(!f){f={}}f.vie=this;return 
new 
this.Findable(f)};c.prototype.loadSchema=function(g,f){f=(!f)?{}:f;if(!g){throw 
new Error("Please provide a proper URL")}else{var 
h=this;d.getJSON(g).success(function(i){c.Util.loadSchemaOrg(h,i,f.baseNS);if(f.success){f.success.call(h)}}).error(function(j,k,i){if(f.error){console.warn(j,k,i);f.error.call(h,"Could
 not load schema from URL ("+g+")")}})}return this};if(typeof 
exports==="object"){exports.VIE=c;if(!d){d=require("jquery")}if(!e){e=require("backbone")}if(!b){b=require("underscore")._}}c.prototype.Able=function(){this.init=function(g,f){this.options=g;this.services=g.from||g.using||g.to||[];this.vie=g.vie;this.methodName=f;this.deferred=d.Deferred();this.resolve=this.deferred.resolve;this.resolveWith=this.deferred.resolveWith;this.reject=this.deferred.rejec
 
t;this.rejectWith=this.deferred.rejectWith;this.success=this.done=this.deferred.done;this.fail=this.deferred.fail;this.then=this.deferred.then;this.always=this.deferred.always;this.from=this.using;this.to=this.using;return
 this};this.using=function(g){var 
f=this;g=(b.isArray(g))?g:[g];b.each(g,function(h){var i=(typeof 
h==="string")?f.vie.service(h):h;f.services.push(i)});return 
this};this.execute=function(){var 
f=this;b(this.services).each(function(g){g[f.methodName](f)});return 
this}};c.prototype.Loadable=function(f){this.init(f,"load")};c.prototype.Loadable.prototype=new
 
c.prototype.Able();c.prototype.Savable=function(f){this.init(f,"save")};c.prototype.Savable.prototype=new
 
c.prototype.Able();c.prototype.Removable=function(f){this.init(f,"remove")};c.prototype.Removable.prototype=new
 
c.prototype.Able();c.prototype.Analyzable=function(f){this.init(f,"analyze")};c.prototype.Analyzable.prototype=new
 c.prototype.Able();c.prototype.Findable=function(f){this.init(f,"find")};c.
 prototype.Findable.prototype=new 
c.prototype.Able();c.Util={toCurie:function(g,j,i){if(c.Util.isCurie(g,i)){return
 g}var l=":";for(var f in i.toObj()){if(g.indexOf(i.get(f))===1){var h=new 
RegExp("^<?"+i.get(f));if(f===""){l=""}return((j)?"[":"")+g.replace(h,f+l).replace(/>$/,"")+((j)?"]":"")}}throw
 new Error("No prefix found for URI 
'"+g+"'!")},isCurie:function(f,g){if(c.Util.isUri(f)){return 
false}else{try{c.Util.toUri(f,g);return true}catch(h){return 
false}}},toUri:function(f,i){var j=":";for(var h in 
i.toObj()){if(h!==""&&(f.indexOf(h+":")===0||f.indexOf("["+h+":")===0)){var 
g=new 
RegExp("^\\[{0,1}"+h+j);return"<"+f.replace(g,i.get(h)).replace(/\]{0,1}$/,"")+">"}}if(f.indexOf(j)===-1){return"<"+i.base()+f+">"}throw
 new Error("No prefix found for CURIE 
'"+f+"'!")},isUri:function(f){return(typeof 
f==="string"&&f.search(/^<.+>$/)===0)},rdf2Entities:function(m,g){if(typeof 
d.rdf!=="function"){return c.Util._rdf2EntitiesNoRdfQuery(m,g)}try{var l=(g 
instanceof d.rdf)?g:d.rdf()
 .load(g,{});l.base(m.vie.namespaces.base());if(m.rules){var 
p=d.rdf.ruleset();for(var j in 
m.vie.namespaces.toObj()){if(j!==""){p.prefix(j,m.vie.namespaces.get(j))}}for(var
 h=0;h<m.rules.length;h++){if(m.rules.hasOwnProperty(h)){var 
o=m.rules[h];p.add(o.left,o.right)}}l=l.reason(p,10)}var k={};l.where("?subject 
?property ?object").each(function(){var 
q=this.subject.toString();if(!k[q]){k[q]={"@subject":q,"@context":m.vie.namespaces.toObj(true),"@type":[]}}var
 s=this.property.toString();var 
t;try{t=m.vie.namespaces.curie(s)}catch(r){t=s;console.warn(s+" doesn't have a 
namespace definition in 
'",m.vie.namespaces.toObj())}k[q][t]=k[q][t]||[];function i(u){if(typeof 
u.value==="string"){if(u.lang){return u.toString()}else{return u.value}return 
u.value.toString()}else{if(u.type==="uri"){return u.toString()}else{return 
u.value}}}k[q][t].push(i(this.object))});b(k).each(function(i){i["@type"]=i["@type"].concat(i["rdf:type"]);delete
 i["rdf:type"];b(i).each(function(r,q){if(r.length==
 =1){i[q]=r[0]}})});var f=[];d.each(k,function(){var i=new 
m.vie.Entity(this);i=m.vie.entities.addOrUpdate(i);f.push(i)});return 
f}catch(n){console.warn("Something went wrong while parsing the returned 
results!",n);return[]}},_rdf2EntitiesNoRdfQuery:function(f,g){var 
h=[];b.forEach(g,function(k,j){var 
i={};i["@subject"]="<"+j+">";b.forEach(k,function(m,l){l="<"+l+">";b.forEach(m,function(n){if(n.type==="uri"){n.value="<"+n.value+">"}if(i[l]&&!b.isArray(i[l])){i[l]=[i[l]]}if(b.isArray(i[l])){i[l].push(n.value);return}i[l]=n.value})});h.push(i)});return
 h},loadSchemaOrg:function(m,k,n){if(!k){throw new Error("Please load the 
schema.json file.")}m.types.remove("<http://schema.org/Thing>");var 
h=(n)?n:m.namespaces.base();m.namespaces.base(n);var 
i={DataType:"xsd:anyType",Boolean:"xsd:boolean",Date:"xsd:date",Float:"xsd:float",Integer:"xsd:integer",Number:"xsd:anySimpleType",Text:"xsd:string",URL:"xsd:anyURI"};var
 j=function(t,u){var s=m.types.add(u,[{id:"value",range:i[u]}]);for(
 var r=0;r<t.length;r++){var 
q=(m.types.get(t[r]))?m.types.get(t[r]):j.call(m,k.datatypes[t[r]].supertypes,t[r]);s.inherit(q)}return
 s};for(var g in k.datatypes){if(!m.types.get(g)){var 
p=k.datatypes[g].supertypes;j.call(m,p,g)}}var l=function(v){var t=[];var 
r=k.types[v]["specific_properties"];for(var u=0;u<r.length;u++){var s=r[u];var 
q=k.properties[s]["ranges"];t.push({id:s,range:q})}return t};var 
f=function(u,v,t){var s=m.types.add(v,t);for(var r=0;r<u.length;r++){var 
q=(m.types.get(u[r]))?m.types.get(u[r]):f.call(m,k.types[u[r]].supertypes,u[r],l.call(m,u[r]));s.inherit(q)}if(v==="Thing"&&!s.isof("owl:Thing")){s.inherit("owl:Thing")}return
 s};for(var o in k.types){if(!m.types.get(o)){var 
p=k.types[o].supertypes;f.call(m,p,o,l.call(m,o))}}m.namespaces.base(h)},xsdDateTime:function(g){function
 l(p){var o=p.toString();return o.length<2?"0"+o:o}var m=g.getFullYear();var 
k=l(g.getMonth()+1);var f=l(g.getDate());var i=l(g.getHours());var 
j=l(g.getMinutes());var h=l(g.getSecond
 s());return 
m+"-"+k+"-"+f+"T"+i+":"+j+":"+h},transformationRules:function(f){var 
g=[{left:["?subject a dbpedia:Person","?subject rdfs:label 
?label"],right:function(h){return 
function(){return[d.rdf.triple(this.subject.toString(),"a","<"+h.base()+"Person>",{namespaces:h.toObj()}),d.rdf.triple(this.subject.toString(),"<"+h.base()+"name>",this.label,{namespaces:h.toObj()})]}}(f.vie.namespaces)},{left:["?subject
 a foaf:Person","?subject rdfs:label ?label"],right:function(h){return 
function(){return[d.rdf.triple(this.subject.toString(),"a","<"+h.base()+"Person>",{namespaces:h.toObj()}),d.rdf.triple(this.subject.toString(),"<"+h.base()+"name>",this.label,{namespaces:h.toObj()})]}}(f.vie.namespaces)},{left:["?subject
 a dbpedia:Place","?subject rdfs:label ?label"],right:function(h){return 
function(){return[d.rdf.triple(this.subject.toString(),"a","<"+h.base()+"Place>",{namespaces:h.toObj()}),d.rdf.triple(this.subject.toString(),"<"+h.base()+"name>",this.label.toString(),{namespaces:
 h.toObj()})]}}(f.vie.namespaces)},{left:["?subject a dbpedia:City","?subject 
rdfs:label ?label","?subject dbpedia:abstract ?abs","?subject dbpedia:country 
?country"],right:function(h){return 
function(){return[d.rdf.triple(this.subject.toString(),"a","<"+h.base()+"City>",{namespaces:h.toObj()}),d.rdf.triple(this.subject.toString(),"<"+h.base()+"name>",this.label.toString(),{namespaces:h.toObj()}),d.rdf.triple(this.subject.toString(),"<"+h.base()+"description>",this.abs.toString(),{namespaces:h.toObj()}),d.rdf.triple(this.subject.toString(),"<"+h.base()+"containedIn>",this.country.toString(),{namespaces:h.toObj()})]}}(f.vie.namespaces)},];return
 g}};c.prototype.Entity=function(h,i){h=(h)?h:{};i=(i)?i:{};var g=this;var 
f=function(k,m){var 
l=k;if(m.isUri(k)||k.indexOf("@")===0){}else{if(m.isCurie(k)){l=m.uri(k)}else{if(!m.isUri(k)){if(k.indexOf(":")===-1){l="<"+m.base()+k+">"}else{l="<"+k+">"}}}}return
 l};if(h["@type"]!==undefined){h["@type"]=(b.isArray(h["@type"]))?h["@type"]:[
 
h["@type"]];h["@type"]=b.map(h["@type"],function(k){if(!g.vie.types.get(k)){g.vie.types.add(k).inherit("owl:Thing")}return
 
g.vie.types.get(k).id});h["@type"]=(h["@type"].length===1)?h["@type"][0]:h["@type"]}else{h["@type"]=g.vie.types.get("owl:Thing").id}b.each(h,function(l,k){var
 m=f(k,this.namespaces);if(k!==m){delete h[k];h[m]=l}},g.vie);var 
j=e.Model.extend({idAttribute:"@subject",initialize:function(k,l){if(k["@subject"]){this.id=this["@subject"]=this.toReference(k["@subject"])}else{this.id=this["@subject"]=k["@subject"]=this.cid.replace("c","_:bnode")}return
 this},get:function(k){k=f(k,g.vie.namespaces);var 
l=e.Model.prototype.get.call(this,k);l=(b.isArray(l))?l:[l];l=b.map(l,function(m){if(m!==undefined&&k==="@type"&&g.vie.types.get(m)){return
 g.vie.types.get(m)}else{if(m!==undefined&&g.vie.entities.get(m)){return 
g.vie.entities.get(m)}else{return m}}},this);if(l.length===0){return 
undefined}l=(l.length===1)?l[0]:l;return 
l},has:function(k){k=f(k,g.vie.namespaces);ret
 urn e.Model.prototype.has.call(this,k)},set:function(m,l,n){if(!m){return 
this}if(typeof m==="string"){var o={};o[m]=l;return 
this.set(o,n)}if(m.attributes){m=m.attributes}var 
k=this;b.each(m,function(q,p){var r=f(p,k.vie.namespaces);if(p!==r){delete 
m[p];m[r]=q}},this);b.each(m,function(r,q){if(!r){return}if(q.indexOf("@")===-1){if(r.isCollection){r.each(function(t){k.vie.entities.addOrUpdate(t)})}else{if(r.isEntity){k.vie.entities.addOrUpdate(r);var
 p=new k.vie.Collection();p.add(r);m[q]=p}else{if(b.isArray(r)){}else{if(typeof 
r=="object"){var s=new k.vie.Entity(r,l);k.vie.entities.addOrUpdate(s);var 
p=new k.vie.Collection();p.add(r);m[q]=p}else{}}}}}},this);return 
e.Model.prototype.set.call(this,m,l)},unset:function(k,l){k=f(k,g.vie.namespaces);return
 e.Model.prototype.unset.call(this,k,l)},getSubject:function(){if(typeof 
this.id==="undefined"){this.id=this.attributes[this.idAttribute]}if(typeof 
this.id==="string"){if(this.id.substr(0,7)==="http://";||this.id.substr(0,4)==
 ="urn:"){return this.toReference(this.id)}return this.id}return 
this.cid.replace("c","_:bnode")},getSubjectUri:function(){return 
this.fromReference(this.getSubject())},toReference:function(m){var 
l=this.vie.namespaces;var 
k=m;if(m.substring(0,2)==="_:"){k=m}else{if(l.isCurie(m)){k=l.uri(m);if(k==="<"+l.base()+m+">"){k="<"+m+">"}}else{if(!l.isUri(m)){k="<"+m+">"}}}return
 k},fromReference:function(l){var k=this.vie.namespaces;if(!k.isUri(l)){return 
l}return l.substring(1,l.length-1)},as:function(k){if(k==="JSON"){return 
this.toJSON()}if(k==="JSONLD"){return this.toJSONLD()}throw new Error("Unknown 
encoding "+k)},toJSONLD:function(){var l={};var 
k=this;b.each(k.attributes,function(o,n){var m=o;if(o instanceof 
k.vie.Collection){m=o.map(function(p){return 
p.getSubject()})}l[n]=m});l["@subject"]=k.getSubject();return 
l},setOrAdd:function(m,l){var k=this;if(typeof 
m==="string"&&l){k._setOrAddOne(m,l)}else{if(typeof 
m==="object"){b(m).each(function(o,n){k._setOrAddOne(n,o)})}}return
  
this},_setOrAddOne:function(l,o){if(!l||!o){return}l=f(l,g.vie.namespaces);if(b.isArray(o)){for(var
 m=0;m<o.length;m++){this._setOrAddOne(l,o[m])}return}if(l==="@type"&&o 
instanceof g.vie.Type){o=o.id}var p={};var 
n=e.Model.prototype.get.call(this,l);if(!n){p[l]=o;this.set(p)}else{if(n.isCollection){if(o.isCollection){o.each(function(q){n.add(q)})}else{if(o.isEntity){n.add(o)}else{if(typeof
 o==="object"){o=new this.vie.Entity(o);n.add(o)}else{throw new Error("you 
cannot add a literal to a collection of 
entities!")}}}this.trigger("change:"+l,this,o,{});this.change({})}else{if(b.isArray(n)){if(o.isCollection){throw
 new Error("you cannot add a collection of entities to an array of 
literals!")}else{if(o.isEntity){this._setOrAddOne(l,o.getSubject())}else{if(typeof
 o==="object"){throw new Error("you cannot add an entity of entities to an 
array of 
literals!")}else{n.push(o);p[l]=n;this.set(p)}}}}else{if(o.isCollection){throw 
new Error("you cannot add a collection of entities to a 
 
literal!")}else{if(o.isEntity){this._setOrAddOne(l,o.getSubject())}else{if(typeof
 o==="object"){throw new Error("you cannot add an entity of entities to a 
literal!")}else{var 
k=[];k.push(n);k.push(o);p[l]=k;this.set(p)}}}}}}return},hasType:function(k){k=g.vie.types.get(k);return
 this.hasPropertyValue("@type",k)},hasPropertyValue:function(m,l){var 
k=this.get(m);if(!(l instanceof Object)){l=g.vie.entities.get(l)}if(k 
instanceof Array){return k.indexOf(l)!==-1}else{return 
k===l}},isof:function(m){var l=this.get("@type");if(l===undefined){return 
false}l=(b.isArray(l))?l:[l];m=(g.vie.types.get(m))?g.vie.types.get(m):new 
g.vie.Type(m);for(var 
k=0;k<l.length;k++){if(g.vie.types.get(l[k])){if(g.vie.types.get(l[k]).isof(m)){return
 true}}else{var n=new g.vie.Type(l[k]);if(n.id===m.id){return true}}}return 
false},addTo:function(l,m){var k=this;if(l instanceof 
k.vie.Collection){if(m){l.addOrUpdate(k)}else{l.add(k)}return this}throw new 
Error("Please provide a proper collection of type V
 IE.Collection as argument!")},isEntity:true,vie:g.vie});return new 
j(h,i)};c.prototype.Collection=e.Collection.extend({model:c.prototype.Entity,get:function(f){if(f===null){return
 null}f=(f.getSubject)?f.getSubject():f;if(typeof 
f==="string"&&f.indexOf("_:")===0){if(f.indexOf("bnode")===2){f=f.replace("_:bnode","c");return
 this._byCid[f]}else{return 
this._byId["<"+f+">"]}}else{f=this.toReference(f);return 
this._byId[f]}},addOrUpdate:function(g,f){f||(f={});var k=this;var 
i;if(b.isArray(g)){var 
j=[];b.each(g,function(l){j.push(k.addOrUpdate(l,f))});return 
j}if(!g.isEntity){g=new 
this.model(g)}if(g.id&&this.get(g.id)){i=this.get(g.id)}if(this.getByCid(g.cid)){var
 i=this.getByCid(g.cid)}if(i){var 
h={};b.each(g.attributes,function(n,m){if(!i.has(m)){h[m]=n;return 
true}else{if(i.get(m)===n){return true}else{var o=i.attributes[m];var l=n;if(o 
instanceof k.vie.Collection){return 
true}if(m==="@context"){h[m]=d.extend(true,{},o,l)}else{o=(d.isArray(o))?o:[o];l=(d.isArray(l))?l:[l];h[
 
m]=b.uniq(o.concat(l));h[m]=(h[m].length===1)?h[m][0]:h[m]}}}});if(!b.isEmpty(h)){i.set(h,f.updateOptions)}return
 i}this.add(g,f.addOptions);return g},isReference:function(f){var g=new 
RegExp("^\\<([^\\>]*)\\>$");if(g.exec(f)){return true}return 
false},toReference:function(f){if(this.isReference(f)){return 
f}return"<"+f+">"},fromReference:function(f){if(!this.isReference(f)){return 
f}return 
f.substring(1,f.length-1)},isCollection:true});if(c.prototype.Type){throw new 
Error("ERROR: VIE.Type is already defined. Please check your 
installation!")}if(c.prototype.Types){throw new Error("ERROR: VIE.Types is 
already defined. Please check your 
installation!")}c.prototype.Type=function(g,f){if(g===undefined||typeof 
g!=="string"){throw"The type constructor needs an 'id' of type string! E.g., 
'Person'"}this.id=this.vie.namespaces.isUri(g)?g:this.vie.namespaces.uri(g);if(this.vie.types.get(this.id)){throw
 new Error("The type "+this.id+" is already defined!")}this.supertypes=new 
this.vie.
 Types();this.subtypes=new this.vie.Types();this.attributes=new 
this.vie.Attributes(this,(f)?f:[]);this.isof=function(h){h=this.vie.types.get(h);if(h){return
 h.subsumes(this.id)}else{throw new Error("No valid type 
given")}};this.subsumes=function(h){h=this.vie.types.get(h);if(h){if(this.id===h.id){return
 true}var i=this.subtypes.list();for(var k=0;k<i.length;k++){var 
j=i[k];if(j){if(j.id===h.id||j.subsumes(h)){return true}}}return 
false}else{throw new Error("No valid type 
given")}};this.inherit=function(h){if(typeof 
h==="string"){this.inherit(this.vie.types.get(h))}else{if(h instanceof 
this.vie.Type){h.subtypes.addOrOverwrite(this);this.supertypes.addOrOverwrite(h);try{this.attributes.list()}catch(l){h.subtypes.remove(this);this.supertypes.remove(h);throw
 l}}else{if(d.isArray(h)){for(var 
j=0,k=h.length;j<k;j++){this.inherit(h[j])}}else{throw new Error("Wrong 
argument in VIE.Type.inherit()")}}}return this};this.hierarchy=function(){var 
j={id:this.id,subtypes:[]};var i=this.sub
 types.list();for(var l=0,h=i.length;l<h;l++){var 
k=this.vie.types.get(i[l]);j.subtypes.push(k.hierarchy())}return 
j};this.instance=function(i,j){i=(i)?i:{};j=(j)?j:{};if(j.typeChecking!==false){for(var
 h in i){if(h.indexOf("@")!==0&&!this.attributes.get(h)){throw new 
Error("Cannot create an instance of "+this.id+" as the type does not allow an 
attribute 
'"+h+"'!")}}}if(i["@type"]){i["@type"].push(this.id)}else{i["@type"]=this.id}return
 new this.vie.Entity(i,j)};this.toString=function(){return 
this.id}};c.prototype.Types=function(){this._types={};this.add=function(h,f){if(this.get(h)){throw
 new Error("Type '"+h+"' already registered.")}else{if(typeof h==="string"){var 
g=new this.vie.Type(h,f);this._types[g.id]=g;return g}else{if(h instanceof 
this.vie.Type){this._types[h.id]=h;return h}else{throw new Error("Wrong 
argument to VIE.Types.add()!")}}}return 
this};this.addOrOverwrite=function(g,f){if(this.get(g)){this.remove(g)}return 
this.add(g,f)};this.get=function(g){if(!g){retur
 n undefined}if(typeof g==="string"){var 
f=this.vie.namespaces.isUri(g)?g:this.vie.namespaces.uri(g);return 
this._types[f]}else{if(g instanceof this.vie.Type){return 
this.get(g.id)}}return undefined};this.remove=function(j){var 
f=this.get(j);if(!f){return 
this}if(!f||f.subsumes("owl:Thing")){console.warn("You are not allowed to 
remove 'owl:Thing'.");return this}delete this._types[f.id];var 
g=f.subtypes.list();for(var i=0;i<g.length;i++){var 
h=g[i];if(h.supertypes.list().length===1){this.remove(h)}else{h.supertypes.remove(f.id)}}return
 f};this.toArray=this.list=function(){var f=[];for(var g in 
this._types){f.push(this._types[g])}return f};this.sort=function(i,h){var 
n=this;i=(d.isArray(i))?i:[i];h=(h)?true:false;if(i.length===0){return[]}var 
f=[i[0]];for(var l=1,g=i.length;l<g;l++){var m=i[l];var 
j=n.get(m);if(j){for(var 
k=0;k<f.length;k++){if(j.subsumes(f[k])){f.splice(k,0,m);break}else{if(k===f.length-1){f.push(m)}}}}}if(!h){f.reverse()}return
 f}};if(c.prototype.Attribute){t
 hrow new Error("ERROR: VIE.Attribute is already defined. Please check your VIE 
installation!")}if(c.prototype.Attributes){throw new Error("ERROR: 
VIE.Attributes is already defined. Please check your VIE 
installation!")}c.prototype.Attribute=function(j,f,i,g,h){if(j===undefined||typeof
 j!=="string"){throw new Error("The attribute constructor needs an 'id' of type 
string! E.g., 'Person'")}if(f===undefined){throw new Error("The attribute 
constructor needs 'range'.")}if(i===undefined){throw new Error("The attribute 
constructor needs a 
'domain'.")}this._domain=i;this.id=this.vie.namespaces.isUri(j)?j:this.vie.namespaces.uri(j);this.range=(b.isArray(f))?f:[f];g=g?g:0;this.min=(g>0)?g:0;h=h?h:Number.MAX_VALUE;this.max=(h>=this.min)?h:this.min;this.applies=function(m){if(this.vie.types.get(m)){m=this.vie.types.get(m)}for(var
 n=0,l=this.range.length;n<l;n++){var 
k=this.vie.types.get(this.range[n]);if(k===undefined&&typeof 
m==="string"){if(m===this.range[n]){return true}}else{if(m.iso
 f(this.range[n])){return true}}}return 
false}};c.prototype.Attributes=function(i,h){this._local={};this._attributes={};this.domain=i;this.add=function(n,l,m,j){if(this.get(n)){throw
 new Error("Attribute '"+n+"' already registered for domain 
"+this.domain.id+"!")}else{if(typeof n==="string"){var k=new 
this.vie.Attribute(n,l,this.domain,m,j);this._local[k.id]=k;return k}else{if(n 
instanceof 
this.vie.Attribute){n.domain=this.domain;n.vie=this.vie;this._local[n.id]=n;return
 n}else{throw new Error("Wrong argument to 
VIE.Types.add()!")}}}};this.remove=function(k){var j=this.get(k);if(j.id in 
this._local){delete this._local[j.id];return j}throw new Error("The attribute 
"+k+" is inherited and cannot be removed from the domain 
"+this.domain.id+"!")};this.get=function(k){if(typeof k==="string"){var 
j=this.vie.namespaces.isUri(k)?k:this.vie.namespaces.uri(k);return 
this._inherit()._attributes[j]}else{if(k instanceof this.vie.Attribute){return 
this.get(k.id)}else{throw new Error("Wrong 
 argument in VIE.Attributes.get()")}}};this._inherit=function(){var 
s=d.extend(true,{},this._local);var 
F=b.map(this.domain.supertypes.list(),function(p){return p.attributes});var 
v={};var n={};for(var E=0,t=F.length;E<t;E++){var C=F[E].list();for(var 
u=0,m=C.length;u<m;u++){var A=C[u].id;if(!(A in s)){if(!(A in v)&&!(A in 
n)){v[A]=C[u]}else{if(!n[A]){n[A]={range:[],mins:[],maxs:[]}}if(A in 
v){n[A]["range"]=d.merge(n[A]["range"],v[A].range);n[A]["mins"]=d.merge(n[A]["mins"],[v[A].min]);n[A]["maxs"]=d.merge(n[A]["maxs"],[v[A].max]);delete
 
v[A]}n[A]["range"]=d.merge(n[A]["range"],C[u].range);n[A]["mins"]=d.merge(n[A]["mins"],[C[u].min]);n[A]["maxs"]=d.merge(n[A]["maxs"],[C[u].max]);n[A]["range"]=b.uniq(n[A]["range"]);n[A]["mins"]=b.uniq(n[A]["mins"]);n[A]["maxs"]=b.uniq(n[A]["maxs"])}}}}d.extend(s,v);for(var
 A in n){var z=n[A]["range"];var q=n[A]["mins"];var o=n[A]["maxs"];var 
l=[];for(var w=0,j=z.length;w<j;w++){var B=this.vie.types.get(z[w]);var 
G=false;if(B){for(var u=0;u<j;
 u++){if(u===w){continue}var 
D=this.vie.types.get(z[u]);if(D&&D.isof(B)){G=true;break}}}if(!G){l.push(z[w])}}var
 k=b.max(q);var y=b.min(o);if(k<=y&&y>=0&&k>=0){s[A]=new 
this.vie.Attribute(A,l,this,k,y)}else{throw new Error("This inheritance is not 
allowed because of an invalid minCount/maxCount 
pair!")}}this._attributes=s;return this};this.toArray=this.list=function(l){var 
m=[];var k=this._inherit()._attributes;for(var j in 
k){if(!l||k[j].applies(l)){m.push(k[j])}}return m};h=b.isArray(h)?h:[h];for(var 
g=0,f=h.length;g<f;g++){this.add(h[g].id,h[g].range,h[g].min,h[g].max)}};if(c.prototype.Namespaces){throw
 new Error("ERROR: VIE.Namespaces is already defined. Please check your VIE 
installation!")}c.prototype.Namespaces=function(g,f){if(!g){throw new 
Error("Please provide a base 
namespace!")}this._base=g;this._namespaces=(f)?f:{};if(typeof 
this._namespaces!=="object"||b.isArray(this._namespaces)){throw new Error("If 
you want to initialise VIE namespace prefixes, please provide 
 a proper 
object!")}};c.prototype.Namespaces.prototype.base=function(f){if(!f){return 
this._base}else{if(typeof 
f==="string"){this.removeNamespace(f);this._base=f;return this._base}else{throw 
new Error("Please provide a valid 
namespace!")}}};c.prototype.Namespaces.prototype.add=function(g,f){if(typeof 
g==="object"){for(var h in g){this.add(h,g[h])}return 
this}if(g===""){this.base(f);return 
this}else{if(this.contains(g)&&f!==this._namespaces[g]){throw new Error("ERROR: 
Trying to register namespace prefix mapping ("+g+","+f+")!There is already a 
mapping existing: 
'("+g+","+this.get(g)+")'!")}else{d.each(this._namespaces,function(j,i){if(i===f&&j!==g){throw
 new Error("ERROR: Trying to register namespace prefix mapping 
("+g+","+f+")!There is already a mapping existing: 
'("+j+","+f+")'!")}})}}this._namespaces[g]=f;return 
this};c.prototype.Namespaces.prototype.addOrReplace=function(g,f){if(typeof 
g==="object"){for(var h in g){this.addOrReplace(h,g[h])}return 
this}this.remove(g);thi
 s.removeNamespace(f);return 
this.add(g,f)};c.prototype.Namespaces.prototype.get=function(f){if(f===""){return
 this.base()}return 
this._namespaces[f]};c.prototype.Namespaces.prototype.getPrefix=function(f){var 
g=undefined;d.each(this._namespaces,function(i,h){if(h===f){g=i}});return 
g};c.prototype.Namespaces.prototype.contains=function(f){return(f in 
this._namespaces)};c.prototype.Namespaces.prototype.containsNamespace=function(f){return
 
this.getPrefix(f)!==undefined};c.prototype.Namespaces.prototype.update=function(g,f){this.remove(g);return
 
this.add(g,f)};c.prototype.Namespaces.prototype.updateNamespace=function(g,f){this.removeNamespace(g);return
 
this.add(g,f)};c.prototype.Namespaces.prototype.remove=function(f){if(f){delete 
this._namespaces[f]}return 
this};c.prototype.Namespaces.prototype.removeNamespace=function(f){var 
g=this.getPrefix(f);if(g){delete this._namespaces[g]}return 
this};c.prototype.Namespaces.prototype.toObj=function(f){if(f){return 
d.extend({},this._namesp
 aces)}return 
d.extend({"":this._base},this._namespaces)};c.prototype.Namespaces.prototype.curie=function(f,g){return
 
c.Util.toCurie(f,g,this)};c.prototype.Namespaces.prototype.isCurie=function(f){return
 
c.Util.isCurie(f,this)};c.prototype.Namespaces.prototype.uri=function(f){return 
c.Util.toUri(f,this)};c.prototype.Namespaces.prototype.isUri=c.Util.isUri;c.prototype.ClassicRDFa=function(f){this.vie=f};c.prototype.ClassicRDFa.prototype={readEntities:function(f){var
 g=[];var 
h=this.vie.RDFaEntities.getInstances(f);b.each(h,function(i){g.push(i.toJSONLD())});return
 g},findPredicateElements:function(h,g,f){return 
this.vie.services.rdfa._findPredicateElements(h,g,f)},getPredicate:function(f){return
 this.vie.services.rdfa.getElementPredicate(f)},getSubject:function(f){return 
this.vie.services.rdfa.getElementSubject(f)}};c.prototype.ClassicRDFaEntities=function(f){this.vie=f};c.prototype.ClassicRDFaEntities.prototype={getInstances:function(f){if(!this.vie.services.rdfa){this.vie.us
 e(new this.vie.RdfaService())}var g=null;var 
h=false;this.vie.load({element:f}).from("rdfa").execute().done(function(i){g=i;h=true});while(!h){}return
 g},getInstance:function(f){var g=this.getInstances(f);if(g&&g.length){return 
g.pop()}return 
null}};c.prototype.ClassicEntityManager=function(f){this.vie=f;this.entities=this.vie.entities};c.prototype.ClassicEntityManager.prototype={getBySubject:function(f){return
 this.vie.entities.get(f)},getByJSONLD:function(f){if(typeof 
f==="string"){try{f=d.parseJSON(f)}catch(g){return null}}return 
this.vie.entities.addOrUpdate(f)},initializeCollection:function(){return}};(function(){c.prototype.DBPediaService=function(f){var
 
g={name:"dbpedia",namespaces:{owl:"http://www.w3.org/2002/07/owl#",yago:"http://dbpedia.org/class/yago/",foaf:"http://xmlns.com/foaf/0.1/",georss:"http://www.georss.org/georss/",geo:"http://www.w3.org/2003/01/geo/wgs84_pos#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#";,
 
dbpedia:"http://dbpedia.org/ontology/",dbprop:"http://dbpedia.org/property/",dcelements:"http://purl.org/dc/elements/1.1/"},rules:[]};this.options=d.extend(true,g,f?f:{});this.vie=null;this.name=this.options.name;d.ajaxSetup({converters:{"text
 application/rdf+json":function(h){return 
JSON.parse(h)}},timeout:60000})};c.prototype.DBPediaService.prototype={init:function(){for(var
 f in this.options.namespaces){var 
g=this.options.namespaces[f];this.vie.namespaces.add(f,g)}this.rules=d.extend([],c.Util.transformationRules(this));this.rules=d.merge(this.rules,(this.options.rules)?this.options.rules:[]);this.connector=new
 this.vie.DBPediaConnector(this.options);return this},load:function(l){var 
h=this;var j=l instanceof this.vie.Loadable;if(!j){throw new Error("Invalid 
Loadable passed")}var m=function(o){o=(typeof 
o==="string")?JSON.parse(o):o;b.defer(function(){try{var 
q=c.Util.rdf2Entities(h,o);q=(b.isArray(q))?q:[q];for(var 
p=0;p<q.length;p++){q[p].set("DBPediaServiceLoad",c.Util
 .xsdDateTime(new 
Date()))}q=(q.length===1)?q[0]:q;l.resolve(q)}catch(p){l.reject(p)}})};var 
k=function(o){l.reject(o)};var 
g=(l.options.entity)?l.options.entity:l.options.entities;if(!g){l.reject([])}else{g=(b.isArray(g))?g:[g];var
 n=[];for(var i=0;i<g.length;i++){var f=(typeof 
g[i]==="string")?g[i]:g[i].id;n.push(f)}this.connector.load(n,m,k)}return 
this}};c.prototype.DBPediaConnector=function(f){this.options=f;this.baseUrl="http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&timeout=0"};c.prototype.DBPediaConnector.prototype={load:function(g,l,j,o){if(!o){o={}}var
 
f=this.baseUrl+"&format="+encodeURIComponent("application/rdf+json")+"&query=";if(b.isArray(g)){var
 n="";var h="";for(var m=0;m<g.length;m++){var 
i=(/^<.+>$/.test(g[m]))?g[m]:"<"+g[m]+">";if(m>0){n+=" .";h+=" UNION "}n+=" 
"+i+" ?prop"+m+" ?val"+m;h+=" { "+i+" ?prop"+m+" ?val"+m+" 
}"}f+=encodeURIComponent("CONSTRUCT {"+n+" } WHERE {"+h+" 
}")}else{g=(/^<.+>$/.test(g))?g:"<"+g+">";f+=encodeURICompon
 ent("CONSTRUCT { "+g+" ?prop ?val } WHERE { "+g+" ?prop ?val }")}var 
k=o.format||"application/rdf+json";if(typeof exports!=="undefined"&&typeof 
process!=="undefined"){return 
this._loadNode(f,l,j,o,k)}d.ajax({success:function(p){l(p)},error:j,type:"GET",url:f,accepts:{"application/rdf+json":"application/rdf+json"}});return
 this},_loadNode:function(j,l,g,f,k){var i=require("request");var 
h=i({method:"GET",uri:j,headers:{Accept:k}},function(o,n,m){l(JSON.parse(m))});h.end();return
 this}}})();(function(){c.prototype.OpenCalaisService=function(f){var 
g={name:"opencalais",url:["http://api.opencalais.com/enlighten/rest/"],timeout:60000,namespaces:{opencalaisc:"http://s.opencalais.com/1/pred/",opencalaiscr:"http://s.opencalais.com/1/type/er/",opencalaiscm:"http://s.opencalais.com/1/type/em/e/"},rules:[]};this.options=d.extend(true,g,f?f:{});this.vie=null;this.name=this.options.name;d.ajaxSetup({converters:{"text
 application/rdf+json":function(h){return JSON.parse(h)}},timeout:this.o
 
ptions.timeout})};c.prototype.OpenCalaisService.prototype={init:function(){for(var
 f in this.options.namespaces){var 
g=this.options.namespaces[f];this.vie.namespaces.add(f,g)}this.rules=d.extend([],c.Util.transformationRules(this));this.rules=d.merge(this.rules,(this.options.rules)?this.options.rules:[]);this.connector=new
 this.vie.OpenCalaisConnector(this.options)},analyze:function(l){var f=this;var 
h=l instanceof this.vie.Analyzable;if(!h){throw"Invalid Analyzable passed"}var 
i=l.options.element?l.options.element:d("body");var 
k=f._extractText(i);if(k.length>0){var j=function(m){b.defer(function(){var 
n=c.Util.rdf2Entities(f,m);l.resolve(n)})};var 
g=function(m){l.reject(m)};this.connector.analyze(k,j,g)}else{console.warn("No 
text found in 
element.");l.resolve([])}},_extractText:function(g){if(g.get(0)&&g.get(0).tagName&&(g.get(0).tagName=="TEXTAREA"||g.get(0).tagName=="INPUT"&&g.attr("type","text"))){return
 g.get(0).val()}else{var f=g.text().replace(/\s+/g," ").replace(/\0
 \b\n\r\f\t/g,"");return 
d.trim(f)}}};c.prototype.OpenCalaisConnector=function(f){this.options=f;this.baseUrl=(b.isArray(f.url))?f.url:[f.url];this.enhancerUrlPrefix="/"};c.prototype.OpenCalaisConnector.prototype={analyze:function(l,k,h,g){if(!g){g={urlIndex:0}}if(g.urlIndex>=this.baseUrl.length){h("Could
 not connect to the given OpenCalais endpoints! Please check for their 
setup!");return}var 
f=this.baseUrl[g.urlIndex].replace(/\/$/,"");f+=this.enhancerUrlPrefix;var 
j=g.format||"application/rdf+json";var m=function(u,n,p,q,r){return 
function(){console.error("OpenCalais connection 
error",arguments);u.analyze(n,p,q,b.extend(r,{urlIndex:r.urlIndex+1}))}}(this,l,k,h,g);var
 i=this._prepareData(l);if(typeof exports!=="undefined"&&typeof 
process!=="undefined"){return 
this._analyzeNode(f,i,k,m,g,j)}d.ajax({success:function(o,n,q){var 
p=q.responseText.replace(/<!--[\s\S]*?-->/g,"");k(p)},error:m,type:"POST",url:f,data:i,accept:"text/plain"})},_analyzeNode:function(g,m,l,h,f,k){var
 j=
 require("request");var 
i=j({method:"POST",uri:g,body:m,headers:{Accept:k}},function(p,o,n){try{l({results:JSON.parse(n)})}catch(q){h(q)}});i.end()},_prepareData:function(f){return{licenseID:this.options.api_key,calculareRelevanceScore:"true",enableMetadataType:"GenericRelations,SocialTags",contentType:"text/html",content:f}}}})();(function(){c.prototype.RdfaRdfQueryService=function(f){var
 
g={name:"rdfardfquery",namespaces:{},rules:[]};this.options=d.extend(true,g,f?f:{});this.views=[],this.vie=null;this.name=this.options.name};c.prototype.RdfaRdfQueryService.prototype={init:function(){for(var
 f in this.options.namespaces){var 
g=this.options.namespaces[f];this.vie.namespaces.add(f,g)}this.rules=d.extend([],c.Util.transformationRules(this));this.rules=d.merge(this.rules,(this.options.rules)?this.options.rules:[])},analyze:function(f){return
 this.load(f)},load:function(l){var f=this;var g=l instanceof 
this.vie.Loadable||l instanceof this.vie.Analyzable;if(!g){throw new Error("I
 nvalid Loadable/Analyzable passed")}var 
i=l.options.element?l.options.element:d(document);try{var 
h=d(i).find("[about],[typeof]").rdfa();d.each(d(i).xmlns(),function(n,m){f.vie.namespaces.addOrReplace(n,m.toString())});var
 
k=c.Util.rdf2Entities(this,h);l.resolve(k)}catch(j){l.reject(j)}},save:function(i){var
 g=i instanceof this.vie.Savable;if(!g){i.reject("Invalid Savable 
passed")}if(!i.options.element){i.reject("Unable to write entity to RDFa, no 
element given")}if(!i.options.entity){i.reject("Unable to write to RDFa, no 
entity given")}if(!d.rdf){i.reject("No rdfQuery found.")}var 
f=i.options.entity;var j=[];var 
h=f.get("@type");h=(d.isArray(h))?h[0]:h;h=h.id;j.push(f.getSubject()+" a 
"+h);d(i.options.element).rdfa(j);i.resolve()}}})();(function(){c.prototype.RdfaService=function(f){var
 
g={name:"rdfa",namespaces:{},subjectSelector:"[about],[typeof],[src],html",predicateSelector:"[property],[rel]",rules:[]};this.options=d.extend(true,g,f?f:{});this.views=[],this.vie=null;thi
 
s.name=this.options.name};c.prototype.RdfaService.prototype={init:function(){for(var
 f in this.options.namespaces){var 
g=this.options.namespaces[f];this.vie.namespaces.add(f,g)}this.rules=d.merge([],c.Util.transformationRules(this));this.rules=d.merge(this.rules,(this.options.rules)?this.options.rules:[])},analyze:function(f){return
 this.load(f)},load:function(m){var g=this;var h=m instanceof 
this.vie.Loadable||m instanceof this.vie.Analyzable;if(!h){throw new 
Error("Invalid Loadable/Analyzable passed")}var 
i;if(!m.options.element){if(typeof document==="undefined"){return 
m.resolve([])}i=d(document)}else{i=m.options.element}var 
j=this.xmlns(i);for(var k in j){this.vie.namespaces.addOrReplace(k,j[k])}var 
l=[];var 
f=d(this.options.subjectSelector,i).add(d(i).filter(this.options.subjectSelector)).each(function(){var
 n=g._readEntity(d(this));if(n){l.push(n)}});m.resolve(l)},save:function(g){var 
f=g instanceof this.vie.Savable;if(!f){throw"Invalid Savable 
passed"}if(!g.options.el
 ement){throw"Unable to write entity to RDFa, no element 
given"}if(!g.options.entity){throw"Unable to write to RDFa, no entity 
given"}this._writeEntity(g.options.entity,g.options.element);g.resolve()},_readEntity:function(i){var
 k=this.getElementSubject(i);var j=this._getElementType(i);var n,m,f;var 
h=this._readEntityPredicates(k,i,false);if(d.isEmptyObject(h)){return null}var 
l=this.vie;for(n in h){m=h[n];if(!b.isArray(m)){continue}f=new 
this.vie.Collection();b.each(m,function(o){var 
p=l.entities.addOrUpdate({"@subject":o});f.addOrUpdate(p)});h[n]=f}h["@subject"]=k;if(j){h["@type"]=j}var
 g=new 
this.vie.Entity(h);g=this.vie.entities.addOrUpdate(g,{updateOptions:{silent:true}});this._registerEntityView(g,i);return
 g},_writeEntity:function(g,h){var 
f=this;this._findPredicateElements(this.getElementSubject(h),h,true).each(function(){var
 j=d(this);var i=f.getElementPredicate(j);if(!g.has(i)){return true}var 
k=g.get(i);if(k&&k.isCollection){return true}if(k===f.readElementValue(i,
 j)){return true}f.writeElementValue(i,j,k)});return 
true},_getViewForElement:function(h,f){var 
g;d.each(this.views,function(){if(d(this.el).get(0)===h.get(0)){if(f&&!this.template){return
 true}g=this;return false}});return 
g},_registerEntityView:function(h,i){if(!i.length){return}var f=this;var 
g=this._getViewForElement(i);if(g){return g}g=new 
this.vie.view.Entity({model:h,el:i,tagName:i.get(0).nodeName,vie:this.vie,service:this.name});this.views.push(g);b.each(h.attributes,function(l,j){var
 
k=h.fromReference(h.get(j));if(k.isCollection){d.each(f.getElementByPredicate(j,i),function(){f._registerCollectionView(k,d(this),h)})}});return
 g},_registerCollectionView:function(j,h,g){var 
f=this._getViewForElement(h,true);if(f){return f}var 
i=h.children(":first-child");f=new 
this.vie.view.Collection({owner:g,collection:j,model:j.model,el:h,template:i,service:this,tagName:h.get(0).nodeName});this.views.push(f);return
 f},_getElementType:function(f){var g;if(d(f).attr("typeof")!==this.o
 
ptions.attributeExistenceComparator){g=d(f).attr("typeof");if(g.indexOf("://")!==-1){return"<"+g+">"}else{return
 g}}return null},getElementSubject:function(i){var g=this;if(typeof 
document!=="undefined"){if(i===document){return document.baseURI}}var 
h=undefined;var 
f=null;d(i).closest(this.options.subjectSelector).each(function(){f=this;if(d(this).attr("about")!==g.options.attributeExistenceComparator){h=d(this).attr("about");return
 
true}if(d(this).attr("src")!==g.options.attributeExistenceComparator){h=d(this).attr("src");return
 
true}if(d(this).attr("typeof")!==g.options.attributeExistenceComparator){return 
true}if(d(this).get(0).nodeName==="HTML"){d("base",this).each(function(){h=d(this).attr("href")})}});if(!h){if(f===i){return
 g.getElementSubject(d(i).parent())}return undefined}if(typeof 
h==="object"){return h}if(h.indexOf("_:")===0){return 
h}if(h.indexOf("<")===0){return 
h}return"<"+h+">"},setElementSubject:function(g,f){if(d(f).attr("src")){return 
d(f).attr("src",g)}re
 turn d(f).attr("about",g)},getElementPredicate:function(g){var 
f;g=d(g);f=g.attr("property");if(!f){f=g.attr("rel")}return 
f},getElementBySubject:function(h,g){var f=this;return 
d(g).find(this.options.subjectSelector).add(d(g).filter(this.options.subjectSelector)).filter(function(){if(f.getElementSubject(d(this))!==h){return
 false}return true})},getElementByPredicate:function(g,i){var f=this;var 
h=this.getElementSubject(i);return 
d(i).find(this.options.predicateSelector).add(d(i).filter(this.options.predicateSelector)).filter(function(){var
 
j=f.getElementPredicate(d(this));if(f.vie.namespaces.curie(j)!==f.vie.namespaces.curie(g)){return
 false}if(f.getElementSubject(this)!==h){return false}return 
true})},_readEntityPredicates:function(h,g,j){var f=this;var 
i={};this._findPredicateElements(h,g,true).each(function(){var l=d(this);var 
k=f.getElementPredicate(l);if(k===""){return}var 
m=f.readElementValue(k,l);if(m===null&&!j){return}i[k]=m});if(d(g).get(0).tagName!=="HTML"){d(g).
 parent("[rev]").each(function(){var 
k=d(this).attr("rev");if(!k){return}i[d(this).attr("rev")]=f.getElementSubject(this)})}return
 i},_findPredicateElements:function(i,h,g){var f=this;return 
d(h).find(this.options.predicateSelector).add(d(h).filter(this.options.predicateSelector)).filter(function(){if(f.getElementSubject(this)!==i){return
 false}if(!g){if(!d(this).parents("[property]").length){return true}return 
false}return true})},readElementValue:function(g,i){var 
j=i.attr("content");if(j){return j}var 
l=i.attr("resource");if(l){return["<"+l+">"]}var 
h=i.attr("href");if(h&&i.attr("rel")===g){return["<"+h+">"]}if(i.attr("rel")){var
 k=[];var 
f=this;d(i).children(this.options.subjectSelector).each(function(){k.push(f.getElementSubject(this))});return
 k}return i.html()},writeElementValue:function(f,g,j){if(j instanceof 
Array&&j.length>0){j=j[0]}var 
h=g.attr("content");if(h){g.attr("content",j);return}var 
i=g.attr("resource");if(i){g.attr("resource",j)}g.html(j)},xmlns:function(
 g){var f;if(!g){if(typeof 
document==="undefined"){return{}}f=d(document)}else{f=d(g)}f=f.add(f.parents());var
 
h={};f.each(function(k,n){if(n.attributes){for(k=0;k<n.attributes.length;k+=1){var
 j=n.attributes[k];if(/^xmlns(:(.+))?$/.test(j.nodeName)){var 
m=/^xmlns(:(.+))?$/.exec(j.nodeName)[2]||"";var 
l=j.nodeValue;if(m===""||l!==""){h[m]=j.nodeValue}}}}});return 
h}}})();(function(){c.prototype.StanbolService=function(f){var 
g={name:"stanbol",url:["http://dev.iks-project.eu/stanbolfull"],timeout:60000,namespaces:{semdeski:"http://www.semanticdesktop.org/ontologies/2007/01/19/nie#",semdeskf:"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#",skos:"http://www.w3.org/2004/02/skos/core#",foaf:"http://xmlns.com/foaf/0.1/",opengis:"http://www.opengis.net/gml/",dbpedia:"http://dbpedia.org/ontology/",dbprop:"http://dbpedia.org/property/",owl:"http://www.w3.org/2002/07/owl#",geonames:"http://www.geonames.org/ontology#",enhancer:"http://fise.iks-project.eu/ontology/",entityhub:
 
"http://www.iks-project.eu/ontology/rick/model/",entityhub2:"http://www.iks-project.eu/ontology/rick/query/",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",dcterms:"http://purl.org/dc/terms/",schema:"http://schema.org/",geo:"http://www.w3.org/2003/01/geo/wgs84_pos#"},rules:[{left:["?subject
 a <http://fise.iks-project.eu/ontology/EntityAnnotation>","?subject 
enhancer:entity-type ?type","?subject enhancer:confidence 
?confidence","?subject enhancer:entity-reference ?entity","?subject 
dcterms:relation ?relation","?relation a 
<http://fise.iks-project.eu/ontology/TextAnnotation>","?relation 
enhancer:selected-text ?selected-text","?relation enhancer:selection-context 
?selection-context","?relation enhancer:start ?start","?relation enhancer:end 
?end"],right:["?entity a ?type","?entity enhancer:hasTextAnnotation 
?relation","?entity enhancer:hasEntityAnnotation 
?subject"]}]};this.options=d.extend(true,g,f?f:{});this.vie=null;this.name=th
 is.options.name;d.ajaxSetup({converters:{"text 
application/rdf+json":function(h){return 
JSON.parse(h)}},timeout:this.options.timeout})};c.prototype.StanbolService.prototype={init:function(){for(var
 f in this.options.namespaces){var 
g=this.options.namespaces[f];this.vie.namespaces.add(f,g)}this.rules=d.extend([],c.Util.transformationRules(this));this.rules=d.merge(this.rules,(this.options.rules)?this.options.rules:[]);this.connector=new
 
this.vie.StanbolConnector(this.options);this.vie.types.addOrOverwrite("enhancer:EntityAnnotation",[]).inherit("owl:Thing");this.vie.types.addOrOverwrite("enhancer:TextAnnotation",[]).inherit("owl:Thing");this.vie.types.addOrOverwrite("enhancer:Enhancement",[]).inherit("owl:Thing")},analyze:function(l){var
 f=this;var h=l instanceof this.vie.Analyzable;if(!h){throw"Invalid Analyzable 
passed"}var i=l.options.element?l.options.element:d("body");var 
k=f._extractText(i);if(k.length>0){var j=function(m){b.defer(function(){var 
n=c.Util.rdf2Entities(f,
 m);l.resolve(n)})};var 
g=function(m){l.reject(m)};this.connector.analyze(k,j,g)}else{console.warn("No 
text found in element.");l.resolve([])}},find:function(k){var i=k instanceof 
this.vie.Findable;if(!i){throw"Invalid Findable passed"}var f=this;var 
j=escape(k.options.term);if(!j){console.warn("StanbolConnector: No term to look 
for!");k.resolve([])}var g=(typeof 
k.options.limit==="undefined")?20:k.options.limit;var m=(typeof 
k.options.offset==="undefined")?0:k.options.offset;var 
l=function(n){b.defer(function(){var 
o=c.Util.rdf2Entities(f,n);k.resolve(o)})};var 
h=function(n){k.reject(n)};this.connector.find(j,g,m,l,h)},load:function(k){var 
i=k instanceof this.vie.Loadable;if(!i){throw"Invalid Loadable passed"}var 
f=this;var g=k.options.entity;if(!g){console.warn("StanbolConnector: No entity 
to look for!");k.resolve([])}var j=function(l){b.defer(function(){var 
m=c.Util.rdf2Entities(f,l);k.resolve(m)})};var 
h=function(l){k.reject(l)};this.connector.load(g,j,h)},_extractText:fu
 
nction(g){if(g.get(0)&&g.get(0).tagName&&(g.get(0).tagName=="TEXTAREA"||g.get(0).tagName=="INPUT"&&g.attr("type","text"))){return
 g.get(0).val()}else{var f=g.text().replace(/\s+/g," 
").replace(/\0\b\n\r\f\t/g,"");return 
d.trim(f)}}};c.prototype.StanbolConnector=function(f){f=(f)?f:{};this.options=f;this.baseUrl=(b.isArray(f.url))?f.url:[f.url];this.enhancerUrlPostfix=(f.enhancerUrlPostfix)?f.enhancerUrlPostfix:"/enhancer";this.entityhubUrlPostfix=(f.entityhubUrlPostfix)?f.entityhubUrlPostfix:"/entityhub"};c.prototype.StanbolConnector.prototype={analyze:function(k,j,h,g){if(!g){g={urlIndex:0}}if(g.urlIndex>=this.baseUrl.length){h("Could
 not connect to the given Stanbol endpoints! Please check for their 
setup!");return}var 
f=this.baseUrl[g.urlIndex].replace(/\/$/,"");f+=this.enhancerUrlPostfix;var 
i=g.format||"application/rdf+json";var l=function(r,m,n,p,q){return 
function(){console.error("Stanbol connection 
error",arguments);r.analyze(m,n,p,b.extend(q,{urlIndex:q.urlIndex+1})
 )}}(this,k,j,h,g);if(typeof exports!=="undefined"&&typeof 
process!=="undefined"){return 
this._analyzeNode(f,k,j,l,g,i)}d.ajax({success:function(m){j(m)},error:l,type:"POST",url:f,data:k,dataType:i,contentType:"text/plain",accepts:{"application/rdf+json":"application/rdf+json"}})},_analyzeNode:function(g,m,l,h,f,k){var
 j=require("request");var 
i=j({method:"POST",uri:g,body:m,headers:{Accept:k}},function(p,o,n){try{l({results:JSON.parse(n)})}catch(q){h(q)}});i.end()},load:function(i,k,h,g){if(!g){g={urlIndex:0}}if(g.urlIndex>=this.baseUrl.length){h("Could
 not connect to the given Stanbol endpoints! Please check for their 
setup!");return}i=i.replace(/^</,"").replace(/>$/,"");var 
f=this.baseUrl[g.urlIndex].replace(/\/$/,"");f+=this.entityhubUrlPostfix+"/sites/entity?id="+escape(i);var
 j=g.format||"application/rdf+json";var l=function(r,m,n,p,q){return 
function(){r.load(m,n,p,b.extend(q,{urlIndex:q.urlIndex+1}))}}(this,i,k,h,g);if(typeof
 exports!=="undefined"&&typeof process!=="u
 ndefined"){return 
this._loadNode(f,k,l,g,j)}d.ajax({success:function(m){k(m)},error:l,type:"GET",url:f,data:null,dataType:j,contentType:"text/plain",accepts:{"application/rdf+json":"application/rdf+json"}})},_loadNode:function(j,l,g,f,k){var
 i=require("request");var 
h=i({method:"GET",uri:j,headers:{Accept:k}},function(o,n,m){try{l(JSON.parse(m))}catch(p){g(p)}});h.end();return
 
this},find:function(g,h,i,m,k,n){if(!n){n={urlIndex:0}}if(n.urlIndex>=this.baseUrl.length){k("Could
 not connect to the given Stanbol endpoints! Please check for their 
setup!");return}var 
f=this.baseUrl[n.urlIndex].replace(/\/$/,"");f+=this.entityhubUrlPostfix+"/sites/find";var
 l=n.format||"application/rdf+json";if(i==null){i=0}if(h==null){h=10}var 
j=function(x,q,p,w,r,u,v){return 
function(){x.find(q,p,w,r,u,b.extend(v,{urlIndex:v.urlIndex+1}))}}(this,g,h,i,m,k,n);if(typeof
 exports!=="undefined"&&typeof process!=="undefined"){return 
this._findNode(f,g,h,i,m,j,n,l)}d.ajax({success:function(o){m(o)},error
 
:j,type:"POST",url:f,data:"name="+g+"&limit="+h+"&offset="+i,dataType:l,accepts:{"application/rdf+json":"application/rdf+json"}})},_findNode:function(g,h,i,k,n,l,o,m){var
 j=require("request");var 
f=j({method:"POST",uri:g,headers:{Accept:m},body:"name="+h+"&limit="+i+"&offset="+k},function(r,q,p){try{n(JSON.parse(p))}catch(s){l(s)}});f.end();return
 this}}})();(function(){c.prototype.ZemantaService=function(f){var 
g={name:"zemanta",url:["http://api.zemanta.com/services/rest/0.0/"],timeout:60000,namespaces:{zemanta:"http://s.zemanta.com/ns#"},rules:[{left:["?subject
 a zemanta:Recognition","?subject zemanta:object ?object","?object owl:sameAs 
?entity"],right:["?entity zemanta:hasEntityAnnotation 
?subject"]}]};this.options=d.extend(true,g,f?f:{});this.vie=null;this.name=this.options.name;d.ajaxSetup({converters:{"text
 application/rdf+json":function(h){return 
JSON.parse(h)}},timeout:this.options.timeout})};c.prototype.ZemantaService.prototype={init:function(){for(var
 f in this.opt
 ions.namespaces){var 
g=this.options.namespaces[f];this.vie.namespaces.add(f,g)}this.rules=d.extend([],c.Util.transformationRules(this));this.rules=d.merge(this.rules,(this.options.rules)?this.options.rules:[]);this.connector=new
 
this.vie.ZemantaConnector(this.options);this.vie.types.addOrOverwrite("zemanta:EntityAnnotation",[]).inherit("owl:Thing")},analyze:function(l){var
 f=this;var h=l instanceof this.vie.Analyzable;if(!h){throw"Invalid Analyzable 
passed"}var i=l.options.element?l.options.element:d("body");var 
k=f._extractText(i);if(k.length>0){var j=function(m){b.defer(function(){var 
n=c.Util.rdf2Entities(f,m);l.resolve(n)})};var 
g=function(m){l.reject(m)};this.connector.analyze(k,j,g)}else{console.warn("No 
text found in 
element.");l.resolve([])}},_extractText:function(g){if(g.get(0)&&g.get(0).tagName&&(g.get(0).tagName=="TEXTAREA"||g.get(0).tagName=="INPUT"&&g.attr("type","text"))){return
 g.get(0).val()}else{var f=g.text().replace(/\s+/g," 
").replace(/\0\b\n\r\f\t/g,"");
 return 
d.trim(f)}}};c.prototype.ZemantaConnector=function(f){this.options=f;this.baseUrl=(b.isArray(f.url))?f.url:[f.url];this.enhancerUrlPrefix="/"};c.prototype.ZemantaConnector.prototype={analyze:function(l,k,h,g){if(!g){g={urlIndex:0}}if(g.urlIndex>=this.baseUrl.length){h("Could
 not connect to the given Zemanta endpoints! Please check for their 
setup!");return}var 
f=this.baseUrl[g.urlIndex].replace(/\/$/,"");f+=this.enhancerUrlPrefix;var 
j=g.format||"application/rdf+json";var m=function(u,n,p,q,r){return 
function(){console.error("Zemanta connection 
error",arguments);u.analyze(n,p,q,b.extend(r,{urlIndex:r.urlIndex+1}))}}(this,l,k,h,g);var
 i=this._prepareData(l);if(typeof exports!=="undefined"&&typeof 
process!=="undefined"){return 
this._analyzeNode(f,i,k,m,g,j)}d.ajax({success:function(o,n,q){var 
p=q.responseText.replace(/<z:signature>.*?<\/z:signature>/,"");k(p)},error:m,type:"POST",url:f,data:i})},_analyzeNode:function(g,m,l,h,f,k){var
 j=require("request");var i=j({method
 
:"POST",uri:g,body:m,headers:{Accept:k}},function(p,o,n){try{l({results:JSON.parse(n)})}catch(q){h(q)}});i.end()},_prepareData:function(f){return{method:"zemanta.suggest_markup",format:"rdfxml",api_key:this.options.api_key,text:f,return_rdf_links:1}}}})();if(!c.prototype.view){c.prototype.view={}}c.prototype.view.Collection=e.View.extend({initialize:function(){this.template=this.options.template;this.service=this.options.service;if(!this.service){throw"No
 RDFa service provided to the Collection 
View"}this.owner=this.options.owner;this.entityViews={};b.bindAll(this,"addItem","removeItem","refreshItems");this.collection.bind("add",this.addItem);this.collection.bind("remove",this.removeItem);var
 
f=this;this.collection.forEach(function(g){f.registerItem(g,f.collection)})},addItem:function(h,j){if(j!==this.collection){return}if(!this.template||this.template.length===0){return}var
 g=this.service._registerEntityView(h,this.cloneElement(this.template,h));var 
i=d(g.render().el);if(h.
 
id){this.service.setElementSubject(h.getSubjectUri(),i)}d(this.el).append(i);var
 f=this.service;i.parent("[rev]").each(function(){var k=d(this).attr("rev");var 
l={};l[k]=new 
f.vie.Collection();l[k].addOrUpdate(f.vie.entities.get(f.getElementSubject(this)));h.set(l)});this.trigger("add",g);this.entityViews[h.cid]=g;i.show()},registerItem:function(g,i){var
 h=this.service.getElementBySubject(g.id,this.el);if(!h){return}var 
f=this.service._registerEntityView(g,h);this.entityViews[g.cid]=f},removeItem:function(f){if(!this.entityViews[f.cid]){return}this.trigger("remove",this.entityViews[f.cid]);d(this.entityViews[f.cid].el).remove();delete
 (this.entityViews[f.cid])},refreshItems:function(g){var 
f=this;d(this.el).empty();g.forEach(function(h){f.addItem(h,g)})},cloneElement:function(i,g){var
 j=d(i).clone(false);var 
f=this.service;if(j.attr("about")!==undefined){j.attr("about","")}j.find("[about]").attr("about","");var
 h=this.service.getElementSubject(j);f._findPredicateElements(h,j
 ,false).each(function(){var 
k=f.getElementPredicate(d(this));if(g.get(k)&&g.get(k).isCollection){return 
true}f.writeElementValue(null,d(this),"")});return 
j}});if(!c.prototype.view){c.prototype.view={}}c.prototype.view.Entity=e.View.extend({initialize:function(f){this.service=f.service?f.service:"rdfa";this.vie=f.vie;b.bindAll(this,"render");this.model.bind("change",this.render)},render:function(){this.vie.save({element:this.el,entity:this.model}).to(this.service).execute();return
 this}});var 
a=this;(function(f){if(a.XDomainRequest){f.ajaxTransport(function(h){if(h.crossDomain&&h.async){if(h.timeout){h.xdrTimeout=h.timeout;delete
 h.timeout}var g;return{send:function(j,i){function 
l(m,p,o,n){g.onload=g.onerror=g.ontimeout=f.noop;g=undefined;i(m,p,o,n)}g=new 
XDomainRequest();if(h.dataType){var 
k="header_Accept="+encodeURIComponent(h.dataType);h.url=h.url+(h.url.indexOf("?")===-1?"?":"&")+k}g.open(h.type,h.url);g.onload=function(n,m){l(200,"OK",{text:g.responseText},"Content-Ty
 pe: 
"+g.contentType)};g.onerror=function(m){console.error(JSON.stringify(m));l(404,"Not
 
Found")};if(h.xdrTimeout){g.ontimeout=function(){l(0,"timeout")};g.timeout=h.xdrTimeout}g.send((h.hasContent&&h.data)||null)},abort:function(){if(g){g.onerror=f.noop();g.abort()}}}}})}})(d)})();
\ No newline at end of file

[... 3 lines stripped ...]

Reply via email to