// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,s,r){function n(e,s){function r(e){function s(e,r){for(var n in r)if(r.hasOwnProperty(n)&&0===e.indexOf(n))return e.length===n.length?!0 in r[n]&&r[n][!0]:s(e.slice(n.length),r[n]);return!1}return s(e,o.w)}function n(e){var s=/ ?[\s.()\[\]|\/,<>\-_!?~#:;\u3010\u3002\u3011"] ?/g,r=" "+e.replace(s,"  ")+" ",n=/(\s([a-z0-9]+)?[a-z]\d([a-z0-9]+)?\s)|(\s([a-z0-9]+)?\d[a-z]([a-z0-9]+)?\s)/g,l=r.replace(n," REFTAG "),t=/ +/g,o=l.replace(t," "),a=/\d+(( \d+)+)?/g,i=o.replace(a,"0").trim();return i.split(" ")}function l(e,s){s||(s="");var l=e.toLowerCase(),a=n(l),i=s.toLowerCase();if(i){a.concat(n(i.split("@")[0]));var u=i.split("@")[1].split(".");if(u.length>2&&u[u.length-2].length+u[u.length-1].length>5){var c=n(u[0]);a.push("CS_"+c[0])}}var h,_,d=o.bias.slice(),f=new Set,g=0;for(h=0;h<a.length;h++){var p=r(a[h]);if(p){if(!f.has(a[h])){if(Array.isArray(p))for(_=0;_<p.length;_++)d[_]=d[_]+p[_];else for(_ in p)p.hasOwnProperty(_)&&(d[_]=d[_]+p[_]);f.add(a[h])}}else g+=1}if(g>0)for(h=0;h<o.unk_words_weights.length;h++)d[h]+=o.unk_words_weights[h];var v=[],w=[],E=[],C=[];for(h=0;h<o.usecases.length;h++)o.usecases[h]===t.NoEvent?(v.push([t.NoEvent,d[h]+o.high_recall_threshold]),E.push([t.NoEvent,d[h]+o.high_precision_threshold])):(v.push([o.usecases[h],d[h]]),E.push([o.usecases[h],d[h]])),w.push([o.usecases[h],d[h]]);for(_=0;_<o.locales.length;_++)C.push([o.locales[_],d[h+_]]);return v.sort(function(e,s){return s[1]-e[1]}),w.sort(function(e,s){return s[1]-e[1]}),E.sort(function(e,s){return s[1]-e[1]}),C.sort(function(e,s){return s[1]-e[1]}),{high_recall_model_usecase_results:v,regular_usecase_results:w,high_precision_model_usecase_results:E,locale_results:C,logs:{token_count:a.length,unk_word_count:g}}}s||(s="");var t=loadHelper("UseCaseEnum.js"),o=loadHelper("model.js");return o.usecases=[t.NoEvent,t.Confirmed,t.Cancelled],o.locales=["de_DE","ja_JP","en_US","fr_FR","es_ES","zh_Hans_CN","nl_NL","it_IT","ko_KR"],o.high_recall_threshold=-7.5,o.high_precision_threshold=11.5,o.bias=[0,0,0,0,0,0,0,0,0,0,0,0],o.unk_words_weights=[1,-1,-3,-3,-5,0,-2,-3,-4,-4,-3,-6],l(e,s)}r||(r="");var l,t=n(tokenizeString(s).join(" "),r),o=r.replace(/.*</,"").replace(/>.*/,"").split("@")[1].toLowerCase(),a=loadHelper("use_case_overrides.js")[o],i=loadHelper("UseCaseEnum.js");if(void 0!==a){var u;for(u=0;u<a.cancelled.length;u++)a.cancelled[u].test(s)&&(l=i.Cancelled);for(u=0;u<a.confirmed.length;u++)a.confirmed[u].test(s)&&(l=i.Confirmed);for(u=0;u<a.noevent.length;u++)a.noevent[u].test(s)&&(l=i.NoEvent)}void 0!==l&&(t[e+"_usecase_results"][0][0]=l);var c=loadHelper("locale_overrides.js")[o];return void 0!==c&&(c=c[t.locale_results[0][0]],void 0!==c&&(t.locale_results[0][0]=c)),{use_case:t[e+"_usecase_results"][0][0],locale:t.locale_results[0][0],log:t.logs,isEvent:function(){return this.use_case!==i.NoEvent}}}}).call();