├── .gitignore
├── README.md
├── bower.json
├── dist
├── angular-nlp-compromise.js
└── angular-nlp-compromise.min.js
├── example
├── app.js
└── index.html
├── gulpfile.js
├── package.json
└── src
├── angular-nlp-compromise.js
└── nlp.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | bower_components
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # angular-nlp-compromise
2 | Natural Language Processing in your angularjs application. Based on [nlp_compromise](https://github.com/spencermountain/nlp_compromise) library.
3 |
4 | ## Example:
5 | [small angular example here](http://rawgit.com/kroid/angular-nlp-compromise/master/example/index.html)
6 |
7 | nlp_compromise examples:
8 |
9 | * [Long Text Demo](http://rawgit.com/spencermountain/nlp_compromise/master/client_side/long_demo/index.html)
10 | * [Specific Methods](http://rawgit.com/spencermountain/nlp_compromise/master/client_side/basic_demo/index.html)
11 | * [Realtime Demo](http://rawgit.com/spencermountain/nlp_compromise/master/client_side/cute_demo/index.html)
12 |
13 | [](https://vimeo.com/109880250)
14 |
15 | ## Getting started:
16 | ### Get the code:
17 | Install via **[Bower](http://bower.io/)** `$ bower install --save angular-nlp-compromise`.
18 |
19 | Or [download the release](http://rawgit.com/kroid/angular-nlp-compromise/master/dist/angular-nlp-compromise.js) ([minified](http://rawgit.com/kroid/angular-nlp-compromise/master/dist/angular-nlp-compromise.min.js))
20 |
21 | ### Add module to your application.
22 | #### index.html:
23 | ```html
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | ```
33 | #### app.js
34 | ```javascript
35 | (function() {
36 | angular
37 | .module('app', ['nlpCompromise'])
38 | .controller('AppController', controller);
39 |
40 | controller.$inject = ['nlp']
41 |
42 | function controller(nlp) {
43 | console.log(nlp);
44 | }
45 | })();
46 | ```
47 | ### Documentation
48 | See docs in [nlp_compromise](https://github.com/spencermountain/nlp_compromise) repository.
49 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-nlp-compromise",
3 | "version": "1.1.0",
4 | "description": "Angular js module for nlp_compromise library https://github.com/spencermountain/nlp_compromise",
5 | "keywords": ["nlp", "nltk", "natural", "language", "processing", "angular", "nlp_compromise"],
6 | "main": "./dist/angular-nlp-compromise.js",
7 | "homepage": "https://github.com/Kroid/angular-nlp-compromise",
8 | "authors": [
9 | "George M Kroid "
10 | ],
11 | "license": "MIT",
12 | "ignore": [
13 | "**/.*",
14 | "node_modules",
15 | "bower_components",
16 | "test",
17 | "tests"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/dist/angular-nlp-compromise.min.js:
--------------------------------------------------------------------------------
1 | !function(){function e(){var e=function(){var e=function(){var e=["infinitive","gerund","past","present","doer","future"],n=[["arise","arising","arose","_s","_r"],["babysit","_ting","babysat","_s","_ter"],["be","_ing","was","is",""],["beat","_ing","_","_s","_er"],["become","becoming","became","_s","_r"],["bend","_ing","bent","_s","_er"],["begin","_ning","began","_s","_ner"],["bet","_ting","_","_s","_ter"],["bind","_ing","bound","_s","_er"],["bite","biting","bit","_s","_r"],["bleed","_ing","bled","_s","_er"],["blow","_ing","blew","_s","_er"],["break","_ing","broke","_s","_er"],["breed","_ing","bred","_s","_er"],["bring","_ing","brought","_s","_er"],["broadcast","_ing","_","_s","_er"],["build","_ing","built","_s","_er"],["buy","_ing","bought","_s","_er"],["catch","_ing","caught","_es","_er"],["choose","choosing","chose","_s","_r"],["come","coming","came","_s","_r"],["cost","_ing","_","_s","_er"],["cut","_ting","_","_s","_ter"],["deal","_ing","_t","_s","_er"],["dig","_ging","dug","_s","_ger"],["do","_ing","did","_es","_er"],["draw","_ing","drew","_s","_er"],["drink","_ing","drank","_s","_er"],["drive","driving","drove","_s","_r"],["eat","_ing","ate","_s","_er"],["fall","_ing","fell","_s","_er"],["feed","_ing","fed","_s","_er"],["feel","_ing","felt","_s","_er"],["fight","_ing","fought","_s","_er"],["find","_ing","found","_s","_er"],["fly","_ing","flew","_s","flier"],["forbid","_ing","forbade","_s"],["forget","_ing","forgot","_s","_er"],["forgive","forgiving","forgave","_s","_r"],["freeze","freezing","froze","_s","_r"],["get","_ting","got","_s","_ter"],["give","giving","gave","_s","_r"],["go","_ing","went","_es","_er"],["grow","_ing","grew","_s","_er"],["hang","_ing","hung","_s","_er"],["have","having","had","has"],["hear","_ing","_d","_s","_er"],["hide","hiding","hid","_s","_r"],["hit","_ting","_","_s","_ter"],["hold","_ing","held","_s","_er"],["hurt","_ing","_","_s","_er"],["know","_ing","knew","_s","_er"],["relay","_ing","_ed","_s","_er"],["lay","_ing","laid","_s","_er"],["lead","_ing","led","_s","_er"],["leave","leaving","left","_s","_r"],["lend","_ing","lent","_s","_er"],["let","_ting","_","_s","_ter"],["lie","lying","lay","_s","_r"],["light","_ing","lit","_s","_er"],["lose","losing","lost","_s","_r"],["make","making","made","_s","_r"],["mean","_ing","_t","_s","_er"],["meet","_ing","met","_s","_er"],["pay","_ing","paid","_s","_er"],["put","_ting","_","_s","_ter"],["quit","_ting","_","_s","_ter"],["read","_ing","_","_s","_er"],["ride","riding","rode","_s","_r"],["ring","_ing","rang","_s","_er"],["rise","rising","rose","_s","_r"],["run","_ning","ran","_s","_ner"],["say","_ing","said","_s"],["see","_ing","saw","_s","_r"],["sell","_ing","sold","_s","_er"],["send","_ing","sent","_s","_er"],["set","_ting","_","_s","_ter"],["shake","shaking","shook","_s","_r"],["shine","shining","shone","_s","_r"],["shoot","_ing","shot","_s","_er"],["show","_ing","_ed","_s","_er"],["shut","_ting","_","_s","_ter"],["sing","_ing","sang","_s","_er"],["sink","_ing","sank","_s","_er"],["sit","_ting","sat","_s","_ter"],["slide","sliding","slid","_s","_r"],["speak","_ing","spoke","_s","_er"],["spend","_ing","spent","_s","_er"],["spin","_ning","spun","_s","_ner"],["spread","_ing","_","_s","_er"],["stand","_ing","stood","_s","_er"],["steal","_ing","stole","_s","_er"],["stick","_ing","stuck","_s","_er"],["sting","_ing","stung","_s","_er"],["strike","striking","struck","_s","_r"],["swear","_ing","swore","_s","_er"],["swim","_ing","swam","_s","_mer"],["swing","_ing","swung","_s","_er"],["take","taking","took","_s","_r"],["teach","_ing","taught","_s","_er"],["tear","_ing","tore","_s","_er"],["tell","_ing","told","_s","_er"],["think","_ing","thought","_s","_er"],["throw","_ing","threw","_s","_er"],["understand","_ing","understood","_s"],["wake","waking","woke","_s","_r"],["wear","_ing","wore","_s","_er"],["win","_ning","won","_s","_ner"],["withdraw","_ing","withdrew","_s","_er"],["write","writing","wrote","_s","_r"],["tie","tying","_d","_s","_r"],["obey","_ing","_ed","_s","_er"],["ski","_ing","_ied","_s","_er"],["boil","_ing","_ed","_s","_er"],["miss","_ing","_ed","_","_er"],["act","_ing","_ed","_s","_or"],["compete","competing","_d","_s","competitor"],["being","are","were","are"],["imply","_ing","implied","implies","implier"],["ice","icing","_d","_s","_r"],["develop","_ing","_","_s","_er"],["wait","_ing","_ed","_s","_er"],["aim","_ing","_ed","_s","_er"],["spill","_ing","spilt","_s","_er"],["drop","_ping","_ped","_s","_per"],["head","_ing","_ed","_s","_er"],["log","_ging","_ged","_s","_ger"],["rub","_bing","_bed","_s","_ber"],["smash","_ing","_ed","_es","_er"],["add","_ing","_ed","_s","_er"],["word","_ing","_ed","_s","_er"],["suit","_ing","_ed","_s","_er"],["be","am","was","am",""]],r=n.map(function(n){for(var r={},t=0;te;e++)for(n=o[a[e]].split(","),r=0;re;e++)for(n=s[a[e]].split(","),r=0;re;e+=1)i[l[e]]="a";return"undefined"!=typeof module&&module.exports&&(module.exports=i),i}(),p=function(){var e=[["child","_ren"],["person","people"],["leaf","leaves"],["database","_s"],["quiz","_zes"],["child","_ren"],["stomach","_s"],["sex","_es"],["move","_s"],["shoe","_s"],["goose","geese"],["phenomenon","phenomena"],["barracks","_"],["deer","_"],["syllabus","syllabi"],["index","indices"],["appendix","appendices"],["criterion","criteria"],["man","men"],["sex","_es"],["rodeo","_s"],["epoch","_s"],["zero","_s"],["avocado","_s"],["halo","_s"],["tornado","_s"],["tuxedo","_s"],["sombrero","_s"],["addendum","addenda"],["alga","_e"],["alumna","_e"],["alumnus","alumni"],["bacillus","bacilli"],["cactus","cacti"],["beau","_x"],["château","_x"],["chateau","_x"],["tableau","_x"],["corpus","corpora"],["curriculum","curricula"],["echo","_es"],["embargo","_es"],["foot","feet"],["genus","genera"],["hippopotamus","hippopotami"],["larva","_e"],["libretto","libretti"],["loaf","loaves"],["matrix","matrices"],["memorandum","memoranda"],["mosquito","_es"],["opus","opera"],["ovum","ova"],["ox","_en"],["radius","radii"],["referendum","referenda"],["thief","thieves"],["tooth","teeth"]];
2 | return e=e.map(function(e){return e[1]=e[1].replace("_",e[0]),e}),"undefined"!=typeof module&&module.exports&&(module.exports=e),e}(),g=function(e){"undefined"!=typeof module&&module.exports&&(d=require("../../data/lexicon/abbreviations"));var n=[],r=e.split(/(\S.+?[.\?!])(?=\s+|$|")/g);d=d.concat(["jan","feb","mar","apr","jun","jul","aug","sep","oct","nov","dec","sept","sep"]);var t=new RegExp("\\b("+d.join("|")+")[.!?] ?$","i"),a=new RegExp("[ |.][A-Z].?$","i"),o=new RegExp("\\.\\.\\.*$"),s=r.length;for(i=0;i0&&(n.push(r[i]),r[i]=""));return 0===n.length?[e]:n};"undefined"!=typeof module&&module.exports&&(exports.sentences=g);var h=function(){var e=function(e,n){n=n||{};var r,t,a,i,o,s=n.min_count||1,l=n.max_size||5,u=/[^a-zA-Z'\-]+/g,d=[null],c=[];for(l++,r=1;l>=r;r++)d.push({});for(e=e.replace(u," ").replace(/^\s+/,"").replace(/\s+$/,""),e=e.toLowerCase(),e=e.split(/\s+/),r=0,i=e.length;i>r;r++)for(o=e[r],d[1][o]=(d[1][o]||0)+1,t=2;l>=t&&i>=r+t;t++)o+=" "+e[r+t-1],d[t][o]=(d[t][o]||0)+1;for(r=void 0,a=1;l>=a;a++){c[a]=[];var p=d[a];for(r in p)p.hasOwnProperty(r)&&p[r]>=s&&c[a].push({word:r,count:p[r],size:a})}return c=c.filter(function(e){return null!==e}),c=c.map(function(e){return e=e.sort(function(e,n){return n.count-e.count})})};return"undefined"!=typeof module&&module.exports&&(exports.ngram=e),e}(),m=function(){"undefined"!=typeof module&&module.exports&&(g=require("./sentence").sentences,t=require("../../data/lexicon/multiples"));var e=Object.keys(t).map(function(e){return e.split(" ")}),n=function(e){return e?(e=e.toLowerCase(),e=e.replace(/[,\.!:;\?\(\)]/,""),e=e.replace(/’/g,"'"),e=e.replace(/"/g,""),e.match(/[a-z0-9]/i)?e:""):""},r=function(e){return e.match(/\?$/)?"interrogative":e.match(/\!$/)?"exclamative":"declarative"},a=function(r){for(var t=[],a=r.map(function(e){return n(e)}),i=0;i0&&null!==e.match(/^[A-Z][a-z]/),punctuated:null!==e.match(/[,;:\(\)"]/)||void 0,end:r===t.length-1||void 0,start:0===r||void 0}});return{sentence:e,tokens:i,type:r(e)}})};return"undefined"!=typeof module&&module.exports&&(exports.tokenize=i),i}(),f=function(){var e={2:"²ƻ",3:"³ƷƸƹƺǮǯЗҘҙӞӟӠӡȜȝ",5:"Ƽƽ",8:"Ȣȣ","!":"¡","?":"¿Ɂɂ",a:"ªÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻȀȁȂȃȦȧȺΆΑΔΛάαλАДадѦѧӐӑӒӓƛɅ",b:"ßþƀƁƂƃƄƅɃΒβϐϦБВЪЬбвъьѢѣҌҍҔҕƥƾ",c:"¢©ÇçĆćĈĉĊċČčƆƇƈȻȼͻͼͽϲϹϽϾϿЄСсєҀҁҪҫ",d:"ÐĎďĐđƉƊȡƋƌǷ",e:"ÈÉÊËèéêëĒēĔĕĖėĘęĚěƎƏƐǝȄȅȆȇȨȩɆɇΈΕΞΣέεξϱϵ϶ЀЁЕЭеѐёҼҽҾҿӖӗӘәӚӛӬӭ",f:"ƑƒϜϝӺӻ",g:"ĜĝĞğĠġĢģƓǤǥǦǧǴǵ",h:"ĤĥĦħƕǶȞȟΉΗЂЊЋНнђћҢңҤҥҺһӉӊ",I:"ÌÍÎÏ",i:"ìíîïĨĩĪīĬĭĮįİıƖƗȈȉȊȋΊΐΪίιϊІЇії",j:"ĴĵǰȷɈɉϳЈј",k:"ĶķĸƘƙǨǩΚκЌЖКжкќҚқҜҝҞҟҠҡ",l:"ĹĺĻļĽľĿŀŁłƚƪǀǏǐȴȽΙӀӏ",m:"ΜϺϻМмӍӎ",n:"ÑñŃńŅņŇňʼnŊŋƝƞǸǹȠȵΝΠήηϞЍИЙЛПийлпѝҊҋӅӆӢӣӤӥπ",o:"ÒÓÔÕÖØðòóôõöøŌōŎŏŐőƟƠơǑǒǪǫǬǭǾǿȌȍȎȏȪȫȬȭȮȯȰȱΌΘΟΦΩδθοσόϕϘϙϬϭϴОФоѲѳѺѻѼѽӦӧӨөӪӫ¤ƍΏ",p:"ƤƿΡρϷϸϼРрҎҏÞ",q:"Ɋɋ",r:"ŔŕŖŗŘřƦȐȑȒȓɌɍЃГЯгяѓҐґҒғӶӷſ",s:"ŚśŜŝŞşŠšƧƨȘșȿςϚϛϟϨϩЅѕ",t:"ŢţŤťŦŧƫƬƭƮȚțȶȾΓΤτϮϯТт҂Ҭҭ",u:"µÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưƱƲǓǔǕǖǗǘǙǚǛǜȔȕȖȗɄΰμυϋύϑЏЦЧцџҴҵҶҷҸҹӋӌӇӈ",v:"ƔνѴѵѶѷ",w:"ŴŵƜωώϖϢϣШЩшщѡѿ",x:"×ΧχϗϰХхҲҳӼӽӾӿ",y:"¥ÝýÿŶŷŸƳƴȲȳɎɏΎΥΨΫγψϒϓϔЎУучўѰѱҮүҰұӮӯӰӱӲӳ",z:"ŹźŻżŽžƩƵƶȤȥɀΖζ"},n=[];Object.keys(e).forEach(function(r){e[r].split("").forEach(function(e){n.push([e,r])})});var r={},t={};n.forEach(function(e){r[e[0]]=e[1],t[e[1]]=e[0]});var a=function(e,n){n=n||{},n.percentage=n.percentage||50;var t=e.split("").map(function(e){var t=100*Math.random();return r[e]&&t2)return e;var n=[/^[^aeiou]?ion/,/^[^aeiou]?ised/,/^[^aeiou]?iled/],r=e.length;if(r>1)for(var t=e[r-2]+e[r-1],a=0;ag){u+=g*f,f=.1*f,m=0;continue}if(100>g){u+=g*(.1*f),f=.01*f,m=0;continue}}if(p.match(/^[0-9]\.[0-9]$/))m+=parseFloat(p);else if(parseInt(p,10)!=p)if(void 0===e[p])if(n[p]){if(i)return null;if(o)return null;if(s)return null;o=!0,m+=n[p]}else if(r[p]){if(i)return null;if(o)return null;if(s)return null;s=!0,m+=r[p]}else{if(!t[p])return null;if(l[p])return null;l[p]=!0,i=!1,o=!1,s=!1,0===m?(u=u||1,u*=t[p]):(m*=t[p],u+=m),m=0}else{if(i)return null;if(o)return null;i=!0,m+=e[p]}else m+=parseInt(p,10)}else{if(y)return null;y=!0,u+=m,m=0,i=!1,f=.1}return m&&(u+=(m||1)*f),u*=d};return"undefined"!=typeof module&&module.exports&&(module.exports=a),a}(),x=function(){var e="(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|aug|sept|oct|nov|dec),?",n="([0-9]{1,2}),?",r="([12][0-9]{3})",t=function(e,n){return Object.keys(n).reduce(function(r,t){return r[t]=e[n[t]],r},{})},a=[{reg:String(e)+" "+String(n)+"-"+String(n)+" "+String(r),example:"March 7th-11th 1987",process:function(e){e||(e=[]);var n={month:1,day:2,to_day:3,year:4};return t(e,n)}},{reg:String(n)+" of "+String(e)+" to "+String(n)+" of "+String(e)+" "+String(r),example:"28th of September to 5th of October 2008",process:function(e){e||(e=[]);var n={day:1,month:2,to_day:3,to_month:4,to_year:5};return t(e,n)}},{reg:String(e)+" "+String(n)+" to "+String(e)+" "+String(n)+" "+String(r),example:"March 7th to june 11th 1987",process:function(e){e||(e=[]);var n={month:1,day:2,to_month:3,to_day:4,year:5,to_year:5};return t(e,n)}},{reg:"between "+String(n)+" "+String(e)+" and "+String(n)+" "+String(e)+" "+String(r),example:"between 13 February and 15 February 1945",process:function(e){e||(e=[]);var n={day:1,month:2,to_day:3,to_month:4,year:5,to_year:5};return t(e,n)}},{reg:"between "+String(e)+" "+String(n)+" and "+String(e)+" "+String(n)+" "+String(r),example:"between March 7th and june 11th 1987",process:function(e){e||(e=[]);var n={month:1,day:2,to_month:3,to_day:4,year:5,to_year:5};return t(e,n)}},{reg:String(e)+" "+String(n)+" "+String(r),example:"March 1st 1987",process:function(e){e||(e=[]);var n={month:1,day:2,year:3};return t(e,n)}},{reg:String(n)+" - "+String(n)+" of "+String(e)+" "+String(r),example:"3rd - 5th of March 1969",process:function(e){e||(e=[]);var n={day:1,to_day:2,month:3,year:4};return t(e,n)}},{reg:String(n)+" of "+String(e)+" "+String(r),example:"3rd of March 1969",process:function(e){e||(e=[]);var n={day:1,month:2,year:3};return t(e,n)}},{reg:String(e)+" "+r+",? to "+String(e)+" "+String(r),example:"September 1939 to April 1945",process:function(e){e||(e=[]);var n={month:1,year:2,to_month:3,to_year:4};return t(e,n)}},{reg:String(e)+" "+String(r),example:"March 1969",process:function(e){e||(e=[]);var n={month:1,year:2};return t(e,n)}},{reg:String(e)+" "+n,example:"March 18th",process:function(e){e||(e=[]);var n={month:1,day:2};return t(e,n)}},{reg:String(n)+" of "+e,example:"18th of March",process:function(e){e||(e=[]);var n={month:2,day:1};return t(e,n)}},{reg:r+" ?- ?"+String(r),example:"1997-1998",process:function(e){e||(e=[]);var n={year:1,to_year:2};return t(e,n)}},{reg:r,example:"1998",process:function(e){e||(e=[]);var n={year:1};return t(e,n)}}].map(function(e){return e.reg=new RegExp(e.reg,"g"),e}),i={january:0,february:1,march:2,april:3,may:4,june:5,july:6,august:7,september:8,october:9,november:10,december:11,jan:0,feb:1,mar:2,apr:3,aug:7,sept:8,oct:9,nov:10,dec:11},o=[31,29,31,30,31,30,31,31,30,31,30,31],s=function(e){return e=e.toLowerCase(),e=e.replace(/([0-9])(th|rd|st)/g,"$1")},l=function(e,n){var r;return r=new Date,n=n||{},e.year=parseInt(e.year,10)||void 0,e.day=parseInt(e.day,10)||void 0,e.to_day=parseInt(e.to_day,10)||void 0,e.to_year=parseInt(e.to_year,10)||void 0,e.month=i[e.month],e.to_month=i[e.to_month],void 0!==e.to_month&&void 0===e.month&&(e.month=e.to_month),void 0===e.to_month&&void 0!==e.month&&(e.to_month=e.month),e.to_year&&!e.year&&(e.year=e.to_year),!e.to_year&&e.year&&void 0!==e.to_month&&(e.to_year=e.year),n.assume_year&&!e.year&&(e.year=r.getFullYear()),void 0!==e.day&&(e.day>31||void 0!==e.month&&e.day>o[e.month])&&(e.day=void 0),void 0!==e.to_month&&e.to_month2090||e.year<1200)&&(e.year=void 0,e.to_year=void 0),e={day:e.day,month:e.month,year:e.year,to:{day:e.to_day,month:e.to_month,year:e.to_year}},e.year&&e.day&&void 0!==e.month&&(e.date_object=new Date,e.date_object.setYear(e.year),e.date_object.setMonth(e.month),e.date_object.setDate(e.day)),e.to.year&&e.to.day&&void 0!==e.to.month&&(e.to.date_object=new Date,e.to.date_object.setYear(e.to.year),e.to.date_object.setMonth(e.to.month),e.to.date_object.setDate(e.to.day)),e.year||void 0!==e.month?e:{})},u=function(e,n){n=n||{},e=s(e);for(var r,t,i,o,u=a.length,d=0;u>d;d+=1)if(o=a[d],e.match(o.reg))return i=new RegExp(o.reg.source,"i"),r=i.exec(e),t=o.process(r),l(t,n)};return"undefined"!=typeof module&&module.exports&&(module.exports=u),u}(),J=function(e,n,r){var t=this;return t.word=e||"","undefined"!=typeof module&&module.exports&&(k=require("./to_number"),x=require("./date_extractor"),$=require("../../data/parts_of_speech")),t.date=function(e){return e=e||{},x(t.word,e)},t.is_date=function(){var e=/(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|aug|sept|oct|nov|dec)/i,n=/1?[0-9]:[0-9]{2}/,r=/\b(monday|tuesday|wednesday|thursday|friday|saturday|sunday|mon|tues|wed|thurs|fri|sat|sun)\b/i;return t.word.match(e)||t.word.match(n)||t.word.match(r)?!0:!1},t.number=function(){return t.is_date()?null:k(t.word)},t.which=function(){return t.date()?$.DA:t.number()?$.NU:$.CD}(),t};"undefined"!=typeof module&&module.exports&&(module.exports=J);var j=function(){var e=function(e){if(!e)return null;var n={hour:"an",heir:"an",heirloom:"an",honest:"an",honour:"an",honor:"an",uber:"an"},r=function(e){return e.length<=5&&e.match(/^[A-Z]*$/)?!0:e.length>=4&&e.match(/^([A-Z]\.)*$/)?!0:!1},t={A:!0,E:!0,F:!0,H:!0,I:!0,L:!0,M:!0,N:!0,O:!0,R:!0,S:!0,X:!0},a=[/^onc?e/i,/^u[bcfhjkqrstn][aeiou]/i,/^eul/i];if(n.hasOwnProperty(e))return n[e];if(r(e)&&t.hasOwnProperty(e.substr(0,1)))return"an";for(var i=0;i3?!0:!1},l=function(e){return uncountable_nouns[e]?{plural:e,singular:e}:o(e)?{plural:e,singular:i(e)}:{singular:e,plural:t(e)}},u={inflect:l,is_plural:o,singularize:i,pluralize:t};return"undefined"!=typeof module&&module.exports&&(module.exports=u),u}(),z=function(e,n,r){var t,a,s=this;void 0!==n&&void 0!==r&&(t=n.tokens[r],a=n.tokens[r+i]),s.word=e||"","undefined"!=typeof module&&module.exports&&($=require("../../data/parts_of_speech"),c=require("../../data/lexicon/firstnames"),o=require("../../data/lexicon/honourifics"),N=require("./conjugate/inflect"),j=require("./indefinite_article"));var l={it:"PRP",they:"PRP",i:"PRP",them:"PRP",you:"PRP",she:"PRP",me:"PRP",he:"PRP",him:"PRP",her:"PRP",us:"PRP",we:"PRP",thou:"PRP"},u={itself:1,west:1,western:1,east:1,eastern:1,north:1,northern:1,south:1,southern:1,the:1,one:1,your:1,my:1,today:1,yesterday:1,tomorrow:1,era:1,century:1,it:1},d={his:"he",her:"she",hers:"she",their:"they",them:"they",its:"it"};return s.is_acronym=function(){var e=s.word;return e.length<=5&&e.match(/^[A-Z]*$/)?!0:e.length>=4&&e.match(/^([A-Z]\.)*$/)?!0:!1},s.is_entity=function(){if(!t)return!1;if(t.normalised.length<3||!t.normalised.match(/[a-z]/i))return!1;if(l[t.normalised])return!1;if(u[t.normalised])return!1;if(t.pos){if("NNA"==t.pos.tag)return!1;if("NNO"==t.pos.tag)return!1;if("NNG"==t.pos.tag)return!1;if("NNP"==t.pos.tag)return!0}return t.noun_capital?!0:t.normalised.match(/ /)?!0:t.normalised.match(/\./)?!0:t.normalised.length<5&&t.text.match(/^[A-Z]*$/)?!0:s.is_acronym()?!0:!1},s.conjugate=function(){return N.inflect(s.word)},s.is_plural=function(){return N.is_plural(s.word)},s.article=function(){return s.is_plural()?"the":j(s.word)},s.pluralize=function(){return N.pluralize(s.word)},s.singularize=function(){return N.singularize(s.word)},s.is_person=function(){var e,n,r=["center","centre","memorial","school","bridge","university","house","college","square","park","foundation","institute","club","museum","arena","stadium","ss","of","the","for","and","&","co","sons"];for(n=r.length,e=0;n>e;e++)if(s.word.match(new RegExp("\\b"+r[e]+"\\b","i")))return!1;for(n=o.length,e=0;n>e;e++)if(s.word.match(new RegExp("\\b"+o[e]+"\\.?\\b","i")))return!0;var t=s.word.split(" ").map(function(e){return e.toLowerCase()});return c[t[0]]?!0:t.length>2&&c[t[1]]?!0:s.word.match(/[a-z]{3,20} [a-z]\.? [a-z]{3,20}/i)?!0:!1},s.pronoun=function(){if(s.is_person()){var e=s.word.split(" ").map(function(e){return e.toLowerCase()});return"m"===c[e[0]]||"m"==c[e[1]]?"he":"f"===c[e[0]]||"f"==c[e[1]]?"she":s.word.match(/^(mrs|miss|ms|misses|mme|mlle)\.? /,"i")?"she":s.word.match(/\b(mr|mister|sr|jr)\b/,"i")?"he":"a"===c[e[0]]||"a"==c[e[1]]?"they":e[0].match(/[aeiy]$/)?"she":e[0].match(/[ou]$/)?"he":e[0].match(/(nn|ll|tt)/)?"she":"they"}return s.is_plural()?"they":"it"},s.referenced_by=function(){if(t&&"PRP"!==t.pos.tag&&"PP"!==t.pos.tag){var e=s.pronoun(),a=n.tokens.slice(r+1,n.tokens.length);n.next&&(a=a.concat(n.next.tokens));for(var i=[],o=0;on;n++){e=r[a[n]].length;for(var o=0;e>o;o++)t[r[a[n]][o]]=a[n]}return"undefined"!=typeof module&&module.exports&&(module.exports=t),t}(),R={infinitive:[["(eed)$",{pr:"$1s",g:"$1ing",pa:"$1ed","do":"$1er"}],["(e)(ep)$",{pr:"$1$2s",g:"$1$2ing",pa:"$1pt","do":"$1$2er"}],["(a[tg]|i[zn]|ur|nc|gl|is)e$",{
3 | pr:"$1es",g:"$1ing",pa:"$1ed"}],["([i|f|rr])y$",{pr:"$1ies",g:"$1ying",pa:"$1ied"}],["([td]er)$",{pr:"$1s",g:"$1ing",pa:"$1ed"}],["([bd]l)e$",{pr:"$1es",g:"$1ing",pa:"$1ed"}],["(ish|tch|ess)$",{pr:"$1es",g:"$1ing",pa:"$1ed"}],["(ion|end|e[nc]t)$",{pr:"$1s",g:"$1ing",pa:"$1ed"}],["(om)e$",{pr:"$1es",g:"$1ing",pa:"ame"}],["([aeiu])([pt])$",{pr:"$1$2s",g:"$1$2$2ing",pa:"$1$2"}],["(er)$",{pr:"$1s",g:"$1ing",pa:"$1ed"}],["(en)$",{pr:"$1s",g:"$1ing",pa:"$1ed"}]],present:[["(ies)$",{"in":"y",g:"ying",pa:"ied"}],["(tch|sh)es$",{"in":"$1",g:"$1ing",pa:"$1ed"}],["(ss)es$",{"in":"$1",g:"$1ing",pa:"$1ed"}],["([tzlshicgrvdnkmu])es$",{"in":"$1e",g:"$1ing",pa:"$1ed"}],["(n[dtk]|c[kt]|[eo]n|i[nl]|er|a[ytrl])s$",{"in":"$1",g:"$1ing",pa:"$1ed"}],["(ow)s$",{"in":"$1",g:"$1ing",pa:"ew"}],["(op)s$",{"in":"$1",g:"$1ping",pa:"$1ped"}],["([eirs])ts$",{"in":"$1t",g:"$1tting",pa:"$1tted"}],["(ll)s$",{"in":"$1",g:"$1ing",pa:"$1ed"}],["(el)s$",{"in":"$1",g:"$1ling",pa:"$1led"}],["(ip)es$",{"in":"$1e",g:"$1ing",pa:"$1ed"}],["ss$",{"in":"ss",g:"ssing",pa:"ssed"}],["s$",{"in":"",g:"ing",pa:"ed"}]],gerund:[["pping$",{"in":"p",pr:"ps",pa:"pped"}],["lling$",{"in":"ll",pr:"lls",pa:"lled"}],["tting$",{"in":"t",pr:"ts",pa:"t"}],["ssing$",{"in":"ss",pr:"sses",pa:"ssed"}],["gging$",{"in":"g",pr:"gs",pa:"gged"}],["([^aeiou])ying$",{"in":"$1y",pr:"$1ies",pa:"$1ied","do":"$1ier"}],["(i.)ing$",{"in":"$1e",pr:"$1es",pa:"$1ed"}],["(u[rtcb]|[bdtpkg]l|n[cg]|a[gdkvtc]|[ua]s|[dr]g|yz|o[rlsp]|cre)ing$",{"in":"$1e",pr:"$1es",pa:"$1ed"}],["(ch|sh)ing$",{"in":"$1",pr:"$1es",pa:"$1ed"}],["(..)ing$",{"in":"$1",pr:"$1s",pa:"$1ed"}]],past:[["(ued)$",{pr:"ues",g:"uing",pa:"ued","do":"uer"}],["(e|i)lled$",{pr:"$1lls",g:"$1lling",pa:"$1lled","do":"$1ller"}],["(sh|ch)ed$",{"in":"$1",pr:"$1es",g:"$1ing","do":"$1er"}],["(tl|gl)ed$",{"in":"$1e",pr:"$1es",g:"$1ing","do":"$1er"}],["(ss)ed$",{"in":"$1",pr:"$1es",g:"$1ing","do":"$1er"}],["pped$",{"in":"p",pr:"ps",g:"pping","do":"pper"}],["tted$",{"in":"t",pr:"ts",g:"tting","do":"tter"}],["gged$",{"in":"g",pr:"gs",g:"gging","do":"gger"}],["(h|ion|n[dt]|ai.|[cs]t|pp|all|ss|tt|int|ail|ld|en|oo.|er|k|pp|w|ou.|rt|ght|rm)ed$",{"in":"$1",pr:"$1s",g:"$1ing","do":"$1er"}],["(..[^aeiou])ed$",{"in":"$1e",pr:"$1es",g:"$1ing","do":"$1er"}],["ied$",{"in":"y",pr:"ies",g:"ying","do":"ier"}],["(.o)ed$",{"in":"$1o",pr:"$1os",g:"$1oing","do":"$1oer"}],["(.i)ed$",{"in":"$1",pr:"$1s",g:"$1ing","do":"$1er"}],["([rl])ew$",{"in":"$1ow",pr:"$1ows",g:"$1owing"}],["([pl])t$",{"in":"$1t",pr:"$1ts",g:"$1ting"}]]};R=Object.keys(R).reduce(function(e,n){return e[n]=R[n].map(function(e){var n={reg:new RegExp(e[0],"i"),repl:{infinitive:e[1]["in"],present:e[1].pr,past:e[1].pa,gerund:e[1].g}};return e[1]["do"]&&(n.repl.doer=e[1]["do"]),n}),e},{}),"undefined"!=typeof module&&module.exports&&(module.exports=R);var V=function(){var e=function(e){e=e||"";var n={tie:"tier",dream:"dreamer",sail:"sailer",run:"runner",rub:"rubber",begin:"beginner",win:"winner",claim:"claimant",deal:"dealer",spin:"spinner"},r={aid:1,fail:1,appear:1,happen:1,seem:1,"try":1,say:1,marry:1,be:1,forbid:1,understand:1,bet:1},t=[{reg:/e$/i,repl:"er"},{reg:/([aeiou])([mlgp])$/i,repl:"$1$2$2er"},{reg:/([rlf])y$/i,repl:"$1ier"},{reg:/^(.?.[aeiou])t$/i,repl:"$1tter"}];if(r.hasOwnProperty(e))return null;if(n.hasOwnProperty(e))return n[e];for(var a=0;a4?e.replace(/ed$/,""):e.replace(/d$/,"");var r,t,a,i;return e.match(/[^aeiou]$/)?(a=e+"ing",t=e+"ed",r=e.match(/ss$/)?e+"es":e+"s",i=V(n)):(a=e.replace(/[aeiou]$/,"ing"),t=e.replace(/[aeiou]$/,"ed"),r=e.replace(/[aeiou]$/,"es"),i=V(n)),{infinitive:n,present:r,past:t,gerund:a,doer:i,future:"will "+n}},t=function(e,n){return e.infinitive?(e.gerund||(e.gerund=e.infinitive+"ing"),e.doer||(e.doer=V(e.infinitive)),e.present||(e.present=e.infinitive+"s"),e.past||(e.past=e.infinitive+"ed"),n&&Object.keys(e).forEach(function(r){e[r]=n+e[r]}),e.future||(e.future="will "+e.infinitive),e.perfect||(e.perfect="have "+e.past),e.pluperfect||(e.pluperfect="had "+e.past),e.future_perfect||(e.future_perfect="will have "+e.past),e):e},a=function(i){if(void 0===i)return{};var o=new RegExp("^(.*?) (in|out|on|off|behind|way|with|of|do|away|across|ahead|back|over|under|together|apart|up|upon|aback|down|about|before|after|around|to|forth|round|through|along|onto)$","i");if(i.match(" ")&&i.match(o)){var s=i.match(o,""),l=s[1],u=s[2],d=a(l);return delete d.doer,Object.keys(d).forEach(function(e){d[e]&&(d[e]+=" "+u)}),d}i.match(/^had [a-z]/i)&&(i=i.replace(/^had /i,"")),i.match(/^have [a-z]/i)&&(i=i.replace(/^have /i,"")),i.match(/^will have [a-z]/i)&&(i=i.replace(/^will have /i,"")),i=i.replace(/^will /i,"");var c,p,g=(i.match(/^(over|under|re|anti|full)\-?/i)||[])[0],h=i.replace(/^(over|under|re|anti|full)\-?/i,""),m={},f=e.length;for(p=0;f>p;p++)if(c=e[p],h===c.present||h===c.gerund||h===c.past||h===c.infinitive)return m=JSON.parse(JSON.stringify(e[p])),t(m,g);var y=n(i)||"infinitive";f=R[y].length;var v;for(p=0;f>p;p++)if(v=R[y][p],i.match(v.reg))return m[y]=i,Object.keys(v.repl).forEach(function(e){e===y?m[e]=i:m[e]=i.replace(v.reg,v.repl[e])}),t(m);return r(i)};return"undefined"!=typeof module&&module.exports&&(module.exports=a),a}(),D=function(e,n,r){var t,a,o=this;void 0!==n&&void 0!==r&&(t=n.tokens[r],a=n.tokens[r+i]),o.word=e||"","undefined"!=typeof module&&module.exports&&(S=require("./conjugate/conjugate"),$=require("../../data/parts_of_speech"));var s={is:"CP","will be":"CP",will:"CP",are:"CP",was:"CP",were:"CP"},l={can:"MD",may:"MD",could:"MD",might:"MD",will:"MD","ought to":"MD",would:"MD",must:"MD",shall:"MD",should:"MD"},u={past:"VBD",participle:"VBN",infinitive:"VBP",present:"VBZ",gerund:"VBG"};return o.conjugate=function(){return S(o.word)},o.to_past=function(){return"gerund"===o.form?o.word:S(o.word).past},o.to_present=function(){return S(o.word).present},o.to_future=function(){return"will "+S(o.word).infinitive},o.form=function(){for(var e=["past","present","gerund","infinitive"],n=S(o.word),r=0;ri;i++)for(g=m[f[i]],i2=0;i2i;i++)h[f[i]]="CD";for(y=l.length,i=0;y>i;i++)h[l[i]]="JJ";for(y=d.length,i=0;y>i;i++)h[d[i]]="NNAB";for(y=o.length,i=0;y>i;i++)h[o[i]]="NNAB";for(y=s.length,i=0;y>i;i++)h[s[i]]="NN";for(y=p.length,i=0;y>i;i++)h[p[i][0]]="NN",h[p[i][1]]="NNS";Object.keys(c).forEach(function(e){h[e]="NNP"}),Object.keys(t).forEach(function(e){h[e]=t[e]}),Object.keys(I).forEach(function(e){h[e]=I[e]});var v;for(y=a.length,i=0;y>i;i++)v=S(a[i]),h[v.infinitive]=h[v.infinitive]||"VBP",h[v.past]=h[v.past]||"VBD",h[v.gerund]=h[v.gerund]||"VBG",h[v.present]=h[v.present]||"VBZ",v.doer&&(h[v.doer]=h[v.doer]||"NNA"),v.participle&&(h[v.participle]=h[v.participle]||"VBN");for(y=e.length,i=0;y>i;i++)v=e[i],h[v.infinitive]=h[v.infinitive]||"VBP",h[v.gerund]=h[v.gerund]||"VBG",h[v.past]=h[v.past]||"VBD",h[v.present]=h[v.present]||"VBZ",v.doer&&(h[v.doer]=h[v.doer]||"NNA"),v.participle&&(h[v.future]=h[v.future]||"VB");var b,w;for(y=r.length,i=0;y>i;i++)h[r[i]]="JJ";for(f=Object.keys(n),y=f.length,i=0;y>i;i++)w=f[i],h[w]="JJ",b=M(w),b&&b!==w&&!h[b]&&(h[b]=h[b]||"RB"),b=O(w),!b||b.match(/^more ./)||b===w||h[b]||(h[b]=h[b]||"JJR"),b=E(w),!b||b.match(/^most ./)||b===w||h[b]||(h[b]=h[b]||"JJS");return"undefined"!=typeof module&&module.exports&&(module.exports=h),h}(),L=function(e){var n=this;n.tokens=e||[];var r=function(e){return e.charAt(0).toUpperCase()+e.slice(1)};return n.tense=function(){var e=n.tokens.filter(function(e){return"verb"===e.pos.parent});return e.map(function(e){return e.analysis.tense})},n.to_past=function(){return n.tokens=n.tokens.map(function(e){return"verb"===e.pos.parent&&(e.text=e.analysis.to_past(),e.normalised=e.text),e}),n},n.to_present=function(){return n.tokens=n.tokens.map(function(e){return"verb"===e.pos.parent&&(e.text=e.analysis.to_present(),e.normalised=e.text),e}),n},n.to_future=function(){return n.tokens=n.tokens.map(function(e){return"verb"===e.pos.parent&&(e.text=e.analysis.to_future(),e.normalised=e.text),e}),n},n.insert=function(e,r){r&&e&&n.tokens.splice(r,0,e)},n.negate=function(){for(var e={everyone:"no one",everybody:"nobody",someone:"no one",somebody:"nobody",always:"never",is:"isn't",are:"aren't",was:"wasn't",will:"won't","didn't":"did","wouldn't":"would","couldn't":"could","shouldn't":"should","can't":"can","won't":"will","mustn't":"must","shan't":"shall",shant:"shall",did:"didn't",would:"wouldn't",could:"couldn't",should:"shouldn't",can:"can't",must:"mustn't"},t=0;t4&&e.match(w[n].reg))return $[w[n].pos]},o=function(e,n,r){var t=r.tokens[n-1],a=r.tokens[n+1],i={the:1,a:1,an:1};return"march"!=e.normalised&&"april"!=e.normalised&&"may"!=e.normalised||!(a&&"CD"==a.pos.tag||t&&"CD"==t.pos.tag)||(e.pos=$.CD,e.pos_reason="may_is_date"),a&&"noun"!==e.pos.parent&&"glue"!==e.pos.parent&&"MD"===a.pos.tag&&(e.pos=$.NN,e.pos_reason="before_modal"),t&&"will"==t.normalised&&!t.punctuated&&"noun"==e.pos.parent&&"PRP"!==e.pos.tag&&"PP"!==e.pos.tag&&(e.pos=$.VB,e.pos_reason="after_will"),t&&"i"==t.normalised&&!t.punctuated&&"noun"==e.pos.parent&&(e.pos=$.VB,e.pos_reason="after_i"),t&&"noun"===e.pos.parent&&"PRP"!==e.pos.tag&&"PP"!==e.pos.tag&&"RB"===t.pos.tag&&!t.start&&(e.pos=$.VB,e.pos_reason="after_adverb"),a&&"adjective"===e.pos.parent&&"adjective"===a.pos.parent&&!e.punctuated&&(e.pos=$.RB,e.pos_reason="consecutive_adjectives"),t&&"verb"===e.pos.parent&&i[t.pos.normalised]&&"CP"!=e.pos.tag&&(e.pos=$.NN,e.pos_reason="determiner-verb"),t&&"CP"===t.pos.tag&&"DT"!==e.pos.tag&&"RB"!==e.pos.tag&&"PRP"!==e.pos.tag&&"adjective"!==e.pos.parent&&"value"!==e.pos.parent&&(e.pos=$.JJ,e.pos_reason="copula-adjective"),t&&a&&"CP"===t.pos.tag&&"RB"===e.pos.tag&&"verb"===a.pos.parent&&(r.tokens[n+1].pos=$.JJ,r.tokens[n+1].pos_reason="copula-adverb-adjective"),a&&"PRP"==a.pos.tag&&"PP"!==e.pos.tag&&"noun"==e.pos.parent&&!e.punctuated&&(e.pos=$.VB,e.pos_reason="before_[him|her|it]"),t&&a&&"DT"===t.pos.tag&&"noun"===a.pos.parent&&"verb"===e.pos.parent&&(e.pos=$.JJ,e.pos_reason="determiner-adjective-noun"),t&&"PRP"===t.pos.tag&&"JJ"===e.pos.tag&&(e.pos=$.VB,e.pos_reason="adjective-after-pronoun"),e},s=function(e){for(var n,r,t,a={"i'd":["i","would"],"she'd":["she","would"],"he'd":["he","would"],"they'd":["they","would"],"we'd":["we","would"],"i'll":["i","will"],"she'll":["she","will"],"he'll":["he","will"],"they'll":["they","will"],"we'll":["we","will"],"i've":["i","have"],"they've":["they","have"],"we've":["we","have"],"should've":["should","have"],"would've":["would","have"],"could've":["could","have"],"must've":["must","have"],"i'm":["i","am"],"we're":["we","are"],"they're":["they","are"],cannot:["can","not"]},i=0;i4){var t=e.normalised.substr(r-4,r-1);if(_.hasOwnProperty(t))return e.pos=$[_[t]],
4 | e.pos_reason="wordnet suffix",e}var o=i(e.normalised);return o?(e.pos=o,e.pos_reason="regex suffix",e):parseFloat(e.normalised)?(e.pos=$.CD,e.pos_reason="parsefloat",e):e}),e.tokens=e.tokens.map(function(e,n){return"lexicon"!==e.pos_reason&&e.normalised.match(/.ed$/)&&(e.pos=$.VB,e.pos_reason="ed"),e}),e.tokens=l(e.tokens);var r=null,t="";e.tokens=e.tokens.map(function(n,a){var i=e.tokens[a+1];if(n.pos){if("the"==n.normalised||"a"==n.normalised||"an"==n.normalised||"PP"===n.pos.tag)return r="noun",t=n.pos.name,n;if("PRP"===n.pos.tag&&"PP"!==n.pos.tag||"MD"===n.pos.tag)return r="verb",t=n.pos.name,n}return n.pos&&("verb"==r&&"noun"==n.pos.parent&&(!i||i.pos&&"noun"!=i.pos.parent)&&(i&&i.pos&&i.pos.parent==r||(n.pos=$.VB,n.pos_reason="signal from "+t,r=null)),"noun"==r&&"verb"==n.pos.parent&&(!i||i.pos&&"verb"!=i.pos.parent)&&(i&&i.pos&&i.pos.parent==r||(n.pos=$.NN,n.pos_reason="signal from "+t,r=null))),r&&!n.pos&&(i&&i.pos&&i.pos.parent==r||(n.pos=$[r],n.pos_reason="signal from "+t,r=null)),"verb"===r&&n.pos&&"verb"===n.pos.parent&&(r=null),"noun"===r&&n.pos&&"noun"===n.pos.parent&&(r=null),n});var d={};e.tokens.forEach(function(e){e.pos&&(d[e.pos.parent]=!0)}),e.tokens=e.tokens.map(function(e,n){if(!e.pos){if(d.adjective&&d.noun&&!d.verb)return e.pos=$.VB,e.pos_reason="need one verb",d.verb=!0,e;e.pos=$.NN,e.pos_reason="noun fallback"}return e}),e.tokens=e.tokens.map(function(n,r){return o(n,r,e)}),e.tokens=e.tokens.map(function(n,r){return o(n,r,e)})}),n.dont_combine||(d=d.map(function(e){return r(e)}),d=d.map(function(e){return t(e)})),d=d.map(function(e){var n=new L(e.tokens);return n.type=e.type,n}),d=d.map(function(e){return e.tokens=e.tokens.map(function(n,r){return n.analysis=F[n.pos.parent](n.normalised,e,r),n}),e}),d=d.map(function(e,n){return e.last=d[n-1],e.next=d[n+1],e}),new G(d)};return"undefined"!=typeof module&&module.exports&&(module.exports=d),d}(),T=function(){"undefined"!=typeof module&&module.exports&&(U=require("./pos"));var e=function(e,n){n=n||{};var r=U(e,n).sentences,t=r.reduce(function(e,r){return e.concat(r.entities(n))},[]),a={};return t=t.filter(function(e){return e.analysis.is_person()&&e.normalised.split(" ").forEach(function(e){a[e]=!0}),a[e.normalised]?!1:!0})};return"undefined"!=typeof module&&module.exports&&(module.exports=e),e}();if("undefined"!=typeof module&&module.exports)var F=require("./src/parents/parents"),g=require("./src/methods/tokenization/sentence").sentences,m=require("./src/methods/tokenization/tokenize").tokenize,h=require("./src/methods/tokenization/ngram").ngram,f=require("./src/methods/transliteration/unicode_normalisation"),y=require("./src/methods/syllables/syllable"),W=require("./src/methods/localization/britishize"),b=W.americanize,v=W.britishize,U=require("./src/pos"),T=require("./src/spot");var H={noun:F.noun,adjective:F.adjective,verb:F.verb,adverb:F.adverb,value:F.value,sentences:g,ngram:h,tokenize:m,americanize:b,britishize:v,syllables:y,normalize:f.normalize,denormalize:f.denormalize,pos:U,spot:T};return"undefined"!=typeof module&&module.exports&&(module.exports=H),H}();return e}angular.module("nlpCompromise",[]).factory("nlp",e)}();
--------------------------------------------------------------------------------
/example/app.js:
--------------------------------------------------------------------------------
1 | (function(){
2 | 'use strict';
3 |
4 | angular.module('app', ['nlpCompromise']).controller('AppController', controller);
5 |
6 | controller.$inject = ['$scope', 'nlp'];
7 |
8 | function controller($scope, nlp) {
9 | var vm = this;
10 |
11 | vm.text = "Every inch of wall space is covered by a bookcase. Each bookcase has six shelves, going almost to the ceiling. Some bookshelves are stacked to the brim with hardback books: science, maths, history, and everything else. Other shelves have two layers of paperback science fiction, with the back layer of books propped up on old tissue boxes or lengths of wood, so that you can see the back layer of books above the books in front. And it still isn't enough. Books are overflowing onto the tables and the sofas and making little heaps under the windows.";
12 |
13 | vm.nouns = null;
14 | vm.adjectives = null;
15 | vm.adverbs = null;
16 | vm.verbs = null;
17 | vm.values = null;
18 |
19 | $scope.$watch('vm.text', function(text) {
20 | if (!text) {
21 | vm.nouns = null;
22 | vm.adjectives = null;
23 | vm.adverbs = null;
24 | vm.verbs = null;
25 | vm.values = null;
26 | return;
27 | }
28 |
29 | var pos = nlp.pos(text)
30 |
31 | vm.nouns = pos.nouns().map(function(ele) {
32 | return ele.normalised;
33 | });
34 | vm.nouns = _.uniq(vm.nouns);
35 | vm.nouns = vm.nouns.join(', ');
36 |
37 | vm.adjectives = pos.adjectives().map(function(ele) {
38 | return ele.normalised;
39 | });
40 | vm.adjectives = _.uniq(vm.adjectives);
41 | vm.adjectives = vm.adjectives.join(', ');
42 |
43 | vm.adverbs = pos.adverbs().map(function(ele) {
44 | return ele.normalised;
45 | });
46 | vm.adverbs = _.uniq(vm.adverbs);
47 | vm.adverbs = vm.adverbs.join(', ');
48 |
49 | vm.verbs = pos.verbs().map(function(ele) {
50 | return ele.normalised;
51 | });
52 | vm.verbs = _.uniq(vm.verbs);
53 | vm.verbs = vm.verbs.join(', ');
54 |
55 | vm.values = pos.values().map(function(ele) {
56 | return ele.normalised;
57 | });
58 | vm.values = _.uniq(vm.values);
59 | vm.values = vm.values.join(', ');
60 | });
61 | }
62 |
63 | })();
64 |
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | angular-nlp-compromise example
4 |
5 |
6 |
7 |
8 |
9 |
14 |
15 |
16 |
17 |
Nouns:
18 |
{{ vm.nouns }}
19 |
20 |
21 |
Adjectives:
22 |
{{ vm.adjectives }}
23 |
24 |
25 |
Adverbs:
26 |
{{ vm.adverbs }}
27 |
28 |
29 |
Verbs:
30 |
{{ vm.verbs }}
31 |
32 |
33 |
Values:
34 |
{{ vm.values }}
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | var gulp = require('gulp'),
2 | include = require('gulp-include'),
3 | rename = require("gulp-rename"),
4 | uglify = require('gulp-uglify');
5 |
6 | gulp.task('default', function() {
7 | gulp.src('./src/angular-nlp-compromise.js')
8 | .pipe(include())
9 | .pipe(gulp.dest('./dist'))
10 | .pipe(rename('angular-nlp-compromise.min.js'))
11 | .pipe(uglify())
12 | .pipe(gulp.dest('./dist'))
13 | });
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-nlp-compromise",
3 | "version": "1.1.0",
4 | "description": "Angular js module for nlp_compromise library https://github.com/spencermountain/nlp_compromise",
5 | "keywords": ["nlp", "nltk", "natural", "language", "processing", "angular", "nlp_compromise"],
6 | "main": "./dist/angular-nlp-compromise.js",
7 | "repository": {
8 | "type": "git",
9 | "url": "https://github.com/Kroid/angular-nlp-compromise.git"
10 | },
11 | "author": "George M Kroid ",
12 | "license": "MIT",
13 | "bugs": {
14 | "url": "https://github.com/Kroid/angular-nlp-compromise/issues"
15 | },
16 | "homepage": "https://github.com/Kroid/angular-nlp-compromise",
17 | "devDependencies": {
18 | "gulp": "^3.8.11",
19 | "gulp-include": "^1.1.1",
20 | "gulp-rename": "^1.2.0",
21 | "gulp-uglify": "^1.1.0"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/angular-nlp-compromise.js:
--------------------------------------------------------------------------------
1 | (function(){
2 | // https://github.com/spencermountain/nlp_compromise/issues/62
3 | // 'use strict';
4 |
5 | angular.module('nlpCompromise', []).factory('nlp', factory);
6 |
7 | function factory() {
8 | //= include nlp.js
9 | return nlp;
10 | }
11 |
12 | })();
13 |
--------------------------------------------------------------------------------