JSFiddle - React, Tailwind, and code Playground
by madhugb
JavaScript
var jQuery;
(function(k){function j(a){if(!a||/^\s*$/.test(a))return[];var d="St.,Jr.,Dr.,Mr.,Mrs.,M.S.,Md.,Rev.,Prof.,Sr.".split(","),c=[":)",":-)",":-("],f=/\s[A-Z]\.$/g,a=a.match(/([^\.\?\!\n]+|[\.\?\!][^\s'"]|\.\s+[a-z0-9])+([\.\?\!)\n]+(['"]\s)*|$)/g),b=0;if(!a)return[];for(b=a.length-1;0<b;--b){var g=!1;for(e in d)if(-1!==a[b-1].indexOf(d[e],a[b-1].length-d[e].length)){g=!0;break}g||f.test(a[b-1])&&(g=!0);g&&(a[b-1]+=a[b],a.splice(b,1))}for(b=a.length-1;0<b;--b)for(s in d=a[b].replace(/^\s+|\s+$/g,""),
c)if(0===d.indexOf(c[s])){a[b-1]+=" "+c[s];a[b]=d.substring(c[s].length);break}for(b=a.length-1;0<=b;--b)a[b]=a[b].replace(/^\s+|\s+$/g,""),(null==a[b]||0==a[b].length)&&a.splice(b,1);return null==a?[]:a}function l(a){var d=j(a.subject),c=j(a.body);sentences=d.concat(c);d=[];for(s in sentences){sentence=sentences[s].trim();a:{var c=sentence,f=a.sender.name,b=[],c=c.replace(/^(dear|hey|hi) /i,""),c=c.replace(/^[a-z]+(,|:)\s*/i,""),g=[/please be patient/i,/please note\b/i];for(i in g){pattern=g[i];
var h=c.match(pattern);if(null!=h){c=[];break a}}h=[["congratulating","congratulate"],["wishing","wish"],["supporting","support"],["thanking","thank"],["welcoming","welcome"]];for(i in h)c=c.replace(RegExp("(please) join us in "+h[i][0],"ig"),"$1 "+h[i][1]);g=[[/\b(could|can|would) (you|we) (please\s*)?(.*)$/i,4],[/\b(you|we) may (want to|should) (.*)$/i,3],[/if (each of |any of )?you (could|can) (please\s+)?(.*)$/i,4],[/if (each of |any of )?you (would) (please\s+)(.*)$/i,4],[/don't forget to (.+)/i,
1],[/^please (feel free to |make sure to| be sure to )?(.*)/i,2],[/\.please (feel free to |make sure to| be sure to )?(.*)/i,2],[/why don't you (.*)/i,1],[/(^|and then )(call me)( at home)?( at work)?/i,2],[/(let me know what you think)/i,0],[/(let me know if .*)/i,1]];for(p in g)pattern=g[p][0],h=c.match(pattern),null!=h&&(task=h[g[p][1]],task=task.replace(/\bme\b/,f).replace(/\bmy\b/,f+"'s"),task=task.replace(/\bI am\b/,f+"...