compromise
Advanced tools
Comparing version 7.0.1 to 7.0.2
@@ -5,10 +5,11 @@ { | ||
"description": "natural language processing in the browser", | ||
"version": "7.0.1", | ||
"main": "./builds/nlp_compromise.js", | ||
"version": "7.0.2", | ||
"main": "./builds/compromise.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/nlp-compromise/nlp_compromise.git" | ||
"url": "git://github.com/nlp-compromise/compromise.git" | ||
}, | ||
"scripts": { | ||
"test": "node ./scripts/test.js", | ||
"browsertest": "node ./scripts/browserTest.js", | ||
"build": "node ./scripts/build.js", | ||
@@ -15,0 +16,0 @@ "demo": "node ./scripts/demo.js", |
@@ -127,3 +127,3 @@ 'use strict'; | ||
// console.log(lexicon['muller']); | ||
// console.log(lexicon['years']); | ||
// let t = new Term('shake'); | ||
@@ -130,0 +130,0 @@ // t.tag.Verb = true; |
@@ -7,207 +7,208 @@ 'use strict'; | ||
let arr = [ | ||
"abu", | ||
"adolfo", | ||
"anthony", | ||
"arthur", | ||
"billy", | ||
"bobby", | ||
"bradford", | ||
"bret", | ||
"caleb", | ||
"clifford", | ||
"craig", | ||
"derek", | ||
"doug", | ||
"dwight", | ||
"eli", | ||
"elliot", | ||
"enrique", | ||
"felipe", | ||
"felix", | ||
"francisco", | ||
"frank", | ||
"george", | ||
"glenn", | ||
"greg", | ||
"gregg", | ||
"hans", | ||
"hugh", | ||
"ira", | ||
"isaac", | ||
"kermit", | ||
"leo", | ||
"levi", | ||
"lorenzo", | ||
"percy", | ||
"philip", | ||
"phillip", | ||
"rex", | ||
"ricky", | ||
"shaun", | ||
"shawn", | ||
"steve", | ||
"timothy", | ||
"wilbur", | ||
"williams", | ||
"woodrow", | ||
"youssef", | ||
"mahmoud", | ||
"mustafa", | ||
"hamza", | ||
"tareq", | ||
"ali", | ||
"beshoi", | ||
"mark", | ||
"habib", | ||
"moussa", | ||
"adama", | ||
"abdoulaye", | ||
"modibo", | ||
"mustapha", | ||
"aziz", | ||
"mateo", | ||
"santino", | ||
"davi", | ||
"jacob", | ||
"vicente", | ||
"alonso", | ||
"maximiliano", | ||
"jose", | ||
"jeronimo", | ||
"joshua", | ||
"ajani", | ||
"amir", | ||
"arnav", | ||
"suraj", | ||
"bruno", | ||
"yousouf", | ||
"wei", | ||
"hao", | ||
"yi", | ||
"jun", | ||
"lei", | ||
"aarav", | ||
"reyansh", | ||
"arjun", | ||
"abulfazl", | ||
"reza", | ||
"kathem", | ||
"ori", | ||
"yosef", | ||
"itai", | ||
"moshe", | ||
"ichika", | ||
"itsuki", | ||
"tatsuki", | ||
"asahi", | ||
"haruki", | ||
"tomoharu", | ||
"yuuma", | ||
"taichi", | ||
"saqib", | ||
"abubakr", | ||
"ergi", | ||
"marc", | ||
"eric", | ||
"enzo", | ||
"pol", | ||
"alex", | ||
"marti", | ||
"jakob", | ||
"paul", | ||
"leevi", | ||
"aputsiaq", | ||
"inunnguaq", | ||
"inuk", | ||
"francesco", | ||
"andrea", | ||
"mattia", | ||
"matteo", | ||
"tommaso", | ||
"nikola", | ||
"ilija", | ||
"marko", | ||
"luka", | ||
"antoni", | ||
"jakub", | ||
"franciszek", | ||
"filip", | ||
"stanislaw", | ||
"mikolaj", | ||
"yusuf", | ||
"berat", | ||
"emir", | ||
"ahmet", | ||
"mehmet", | ||
"leroy", | ||
"roy", | ||
"troy", | ||
"floyd", | ||
"lloyd", | ||
"carl", | ||
"earl", | ||
"karl", | ||
"raul", | ||
"saul", | ||
"earnest", | ||
"ernest", | ||
"forrest", | ||
"arnold", | ||
"harold", | ||
"andrew", | ||
"mathew", | ||
"matthew", | ||
"elliott", | ||
"matt", | ||
"scott", | ||
"marty", | ||
"monty", | ||
"scotty", | ||
"clay", | ||
"jay", | ||
"murray", | ||
"monte", | ||
"pete", | ||
"elwood", | ||
"jarrod", | ||
"claude", | ||
"clyde", | ||
"wade", | ||
"alfredo", | ||
"reynaldo", | ||
"wilfredo", | ||
"clark", | ||
"kirk", | ||
"chase", | ||
"jesse", | ||
"cedric", | ||
"dominic", | ||
"josh", | ||
"rocky", | ||
"rodolfo", | ||
"roosevelt", | ||
"roscoe", | ||
"ross", | ||
"jeff", | ||
"jeremy", | ||
"jerome", | ||
"jess", | ||
"toby", | ||
"todd", | ||
"tom", | ||
"tony", | ||
"darryl", | ||
"daryl", | ||
"dave", | ||
"joe", | ||
"john", | ||
"jorge", | ||
"malcolm", | ||
"marco", | ||
"max", | ||
"alfonso", | ||
"alonzo", | ||
"guillermo", | ||
"gustavo" | ||
] | ||
'abu', | ||
'adolfo', | ||
'anthony', | ||
'arthur', | ||
'billy', | ||
'bobby', | ||
'bob', | ||
'bradford', | ||
'bret', | ||
'caleb', | ||
'clifford', | ||
'craig', | ||
'derek', | ||
'doug', | ||
'dwight', | ||
'eli', | ||
'elliot', | ||
'enrique', | ||
'felipe', | ||
'felix', | ||
'francisco', | ||
'frank', | ||
'george', | ||
'glenn', | ||
'greg', | ||
'gregg', | ||
'hans', | ||
'hugh', | ||
'ira', | ||
'isaac', | ||
'kermit', | ||
'leo', | ||
'levi', | ||
'lorenzo', | ||
'percy', | ||
'philip', | ||
'phillip', | ||
'rex', | ||
'ricky', | ||
'shaun', | ||
'shawn', | ||
'steve', | ||
'timothy', | ||
'wilbur', | ||
'williams', | ||
'woodrow', | ||
'youssef', | ||
'mahmoud', | ||
'mustafa', | ||
'hamza', | ||
'tareq', | ||
'ali', | ||
'beshoi', | ||
'mark', | ||
'habib', | ||
'moussa', | ||
'adama', | ||
'abdoulaye', | ||
'modibo', | ||
'mustapha', | ||
'aziz', | ||
'mateo', | ||
'santino', | ||
'davi', | ||
'jacob', | ||
'vicente', | ||
'alonso', | ||
'maximiliano', | ||
'jose', | ||
'jeronimo', | ||
'joshua', | ||
'ajani', | ||
'amir', | ||
'arnav', | ||
'suraj', | ||
'bruno', | ||
'yousouf', | ||
'wei', | ||
'hao', | ||
'yi', | ||
'jun', | ||
'lei', | ||
'aarav', | ||
'reyansh', | ||
'arjun', | ||
'abulfazl', | ||
'reza', | ||
'kathem', | ||
'ori', | ||
'yosef', | ||
'itai', | ||
'moshe', | ||
'ichika', | ||
'itsuki', | ||
'tatsuki', | ||
'asahi', | ||
'haruki', | ||
'tomoharu', | ||
'yuuma', | ||
'taichi', | ||
'saqib', | ||
'abubakr', | ||
'ergi', | ||
'marc', | ||
'eric', | ||
'enzo', | ||
'pol', | ||
'alex', | ||
'marti', | ||
'jakob', | ||
'paul', | ||
'leevi', | ||
'aputsiaq', | ||
'inunnguaq', | ||
'inuk', | ||
'francesco', | ||
'andrea', | ||
'mattia', | ||
'matteo', | ||
'tommaso', | ||
'nikola', | ||
'ilija', | ||
'marko', | ||
'luka', | ||
'antoni', | ||
'jakub', | ||
'franciszek', | ||
'filip', | ||
'stanislaw', | ||
'mikolaj', | ||
'yusuf', | ||
'berat', | ||
'emir', | ||
'ahmet', | ||
'mehmet', | ||
'leroy', | ||
'roy', | ||
'troy', | ||
'floyd', | ||
'lloyd', | ||
'carl', | ||
'earl', | ||
'karl', | ||
'raul', | ||
'saul', | ||
'earnest', | ||
'ernest', | ||
'forrest', | ||
'arnold', | ||
'harold', | ||
'andrew', | ||
'mathew', | ||
'matthew', | ||
'elliott', | ||
'matt', | ||
'scott', | ||
'marty', | ||
'monty', | ||
'scotty', | ||
'clay', | ||
'jay', | ||
'murray', | ||
'monte', | ||
'pete', | ||
'elwood', | ||
'jarrod', | ||
'claude', | ||
'clyde', | ||
'wade', | ||
'alfredo', | ||
'reynaldo', | ||
'wilfredo', | ||
'clark', | ||
'kirk', | ||
'chase', | ||
'jesse', | ||
'cedric', | ||
'dominic', | ||
'josh', | ||
'rocky', | ||
'rodolfo', | ||
'roosevelt', | ||
'roscoe', | ||
'ross', | ||
'jeff', | ||
'jeremy', | ||
'jerome', | ||
'jess', | ||
'toby', | ||
'todd', | ||
'tom', | ||
'tony', | ||
'darryl', | ||
'daryl', | ||
'dave', | ||
'joe', | ||
'john', | ||
'jorge', | ||
'malcolm', | ||
'marco', | ||
'max', | ||
'alfonso', | ||
'alonzo', | ||
'guillermo', | ||
'gustavo' | ||
]; | ||
@@ -220,93 +221,93 @@ | ||
let suffix_compressed = { | ||
"rence": "cla,lau,law,te,ter", | ||
"lbert": "a,de,e,gi,wi", | ||
"berto": "al,gil,hum,ro", | ||
"ustin": "ag,j,a,d", | ||
"rick": "e,frede,rode,der,fred,kend,pat,", | ||
"ardo": "bern,leon,ricc,edu,ger,ric", | ||
"lvin": "e,ke,me,a,ca", | ||
"nnie": "do,lo,ro,be,joh", | ||
"bert": ",her,hu,nor,ro", | ||
"than": "e,na,johna,jona", | ||
"ando": "arm,fern,orl,rol", | ||
"land": "cleve,gar,le,ro", | ||
"arry": "b,g,h,l", | ||
"lton": "a,car,e,mi", | ||
"ian": "sebast,j,,maximil,krist,adr,br,christ,dam,fab,jul", | ||
"ton": "an,clin,quin,bur,clay,clif,pres,wins", | ||
"ter": "car,pe,ches,les,sylves,dex,wal", | ||
"ard": "bern,edw,ger,how,leon,rich,will", | ||
"ell": "darn,darr,low,mitch,russ,terr,wend", | ||
"son": "jack,ma,harri,ja,nel,ty,wil", | ||
"aan": "ish,arm,viv,ay,vih,nom", | ||
"ron": "a,aa,by,came,my,", | ||
"lan": "mi,a,al,dy,har,no", | ||
"man": "abdulrah,us,her,nor,sher,ro", | ||
"mon": "ra,szy,da,si,solo", | ||
"uel": "mig,sam,eman,emman,man", | ||
"don": "bran,,el,gor,shel", | ||
"med": "moha,muha,ah,moham,muham", | ||
"ald": "don,regin,ron,ger,jer", | ||
"vin": "er,ir,mar,de,ke", | ||
"rey": "ca,co,geoff,jeff", | ||
"ett": "br,ever,garr,emm", | ||
"ael": "raf,ism,mich,raph", | ||
"mmy": "ji,sa,ti,to", | ||
"las": "nico,dal,doug,nicho", | ||
"red": "alf,f,wilf,ja", | ||
"nny": "be,da,joh,ke", | ||
"ius": "cornel,dar,demetr,jul", | ||
"ley": "brad,har,stan,wes", | ||
"mar": "o,ou,am,la", | ||
"iel": "gabr,dan,ar,nathan", | ||
"ane": "souleym,d,du,sh", | ||
"ent": "br,k,tr,vinc", | ||
"an": "hass,ju,log,ary,roh,has,eit,yonat,ro,zor,drag,dej,stef,iv,emirh,ev,brend,d,jord,bry,de,esteb,ry,se,st,steph", | ||
"er": "ik,javi,alexand,oliv,aleksand,om,christoph,kristoph,luth,elm,grov,hom,jasp,rodg,rog,spenc,tyl,xavi", | ||
"en": "jayd,jad,aid,dev,eym,b,reub,rub,darr,lor,warr,all,dami,gl,k,ow,steph,stev", | ||
"in": "yass,husse,benjam,mart,joaqu,hosse,col,frankl,marl,darw,edw,erw,dar,darr,efra,quent", | ||
"ie": "j,jimm,samm,tomm,bill,charl,will,ern,arch,edd,frank,fredd,lou,regg,robb", | ||
"is": "alex,lu,lou,math,chr,curt,den,denn,ell,franc,lew,morr,ot,trav,will", | ||
"el": "abd,ang,no,jo,ro,ab,darr,fid,lion,marc,mich,russ", | ||
"ry": "jer,per,ter,co,grego,ro,ga,zacha,hen,jeffe,jeff", | ||
"ce": "lan,terran,van,bru,bry,hora,mauri,roy,walla", | ||
"ne": "deway,dway,way,antoi,blai,jermai,euge,ge,tyro", | ||
"to": "mina,yuu,haru,haruhi,haya,beni,ernes,ot", | ||
"or": "heit,vict,ig,hect,juni,salvad,tayl,trev", | ||
"as": "mati,tom,luc,thom,luk,tobi,jon,eli", | ||
"io": "anton,emil,jul,rogel,gregor,ignac,mar,serg", | ||
"le": "gabrie,doy,ky,ly,da,mer,orvil", | ||
"al": "bil,,h,jam,miche,ne,rand", | ||
"dy": "fred,ted,an,bra,co,gra,ru", | ||
"ad": "muhamm,mohamm,moham,mur,br,ch,conr", | ||
"ey": "dew,harv,jo,mick,rick,rodn,sidn", | ||
"am": "li,willi,no,ad,abrah,grah,s", | ||
"ah": "abdall,no,elij,jeremi,abdull,mic", | ||
"on": "bry,j,jonath,le,marl,vern", | ||
"il": "ne,nikh,cec,em,ph,virg", | ||
"im": "j,t,ibrah,kar,hal,sel", | ||
"go": "santia,thia,die,rodri,domin,hu", | ||
"ar": "ces,hyd,aleksand,pet,edg,osc", | ||
"os": "kiroll,carl,mil,am,marc,sant", | ||
"ro": "ped,alejand,alessand,alva,artu,rami", | ||
"nd": "arma,edmu,desmo,edmo,raymo", | ||
"ck": "ja,chu,domini,ma,ni", | ||
"ta": "hina,haru,sou,ara,kana", | ||
"ou": "l,mamad,mahamad,sek,ry", | ||
"ph": "ral,randol,rudol,jose,joes", | ||
"ik": "er,adv,mal,min,sal", | ||
"rt": "cu,ku,ba,stewa,stua", | ||
"us": "mathe,jes,marc,ruf", | ||
"lo": "ange,pab,abdul,nii", | ||
"es": "jam,andr,charl,mos", | ||
"id": "rach,dav,zah,shah", | ||
"nt": "brya,cli,gra,lamo", | ||
"re": "and,pier,salvato,theodo", | ||
"ng": "irvi,sterli,fe,yo", | ||
"ed": "khal,,n,t", | ||
"ke": "bla,ja,lu,mi", | ||
"th": "hea,kei,kenne,se", | ||
"ll": "carro,kenda,marsha,randa", | ||
"di": "fa,meh,mah,jor" | ||
} | ||
'rence': 'cla,lau,law,te,ter', | ||
'lbert': 'a,de,e,gi,wi', | ||
'berto': 'al,gil,hum,ro', | ||
'ustin': 'ag,j,a,d', | ||
'rick': 'e,frede,rode,der,fred,kend,pat,', | ||
'ardo': 'bern,leon,ricc,edu,ger,ric', | ||
'lvin': 'e,ke,me,a,ca', | ||
'nnie': 'do,lo,ro,be,joh', | ||
'bert': ',her,hu,nor,ro', | ||
'than': 'e,na,johna,jona', | ||
'ando': 'arm,fern,orl,rol', | ||
'land': 'cleve,gar,le,ro', | ||
'arry': 'b,g,h,l', | ||
'lton': 'a,car,e,mi', | ||
'ian': 'sebast,j,,maximil,krist,adr,br,christ,dam,fab,jul', | ||
'ton': 'an,clin,quin,bur,clay,clif,pres,wins', | ||
'ter': 'car,pe,ches,les,sylves,dex,wal', | ||
'ard': 'bern,edw,ger,how,leon,rich,will', | ||
'ell': 'darn,darr,low,mitch,russ,terr,wend', | ||
'son': 'jack,ma,harri,ja,nel,ty,wil', | ||
'aan': 'ish,arm,viv,ay,vih,nom', | ||
'ron': 'a,aa,by,came,my,', | ||
'lan': 'mi,a,al,dy,har,no', | ||
'man': 'abdulrah,us,her,nor,sher,ro', | ||
'mon': 'ra,szy,da,si,solo', | ||
'uel': 'mig,sam,eman,emman,man', | ||
'don': 'bran,,el,gor,shel', | ||
'med': 'moha,muha,ah,moham,muham', | ||
'ald': 'don,regin,ron,ger,jer', | ||
'vin': 'er,ir,mar,de,ke', | ||
'rey': 'ca,co,geoff,jeff', | ||
'ett': 'br,ever,garr,emm', | ||
'ael': 'raf,ism,mich,raph', | ||
'mmy': 'ji,sa,ti,to', | ||
'las': 'nico,dal,doug,nicho', | ||
'red': 'alf,f,wilf,ja', | ||
'nny': 'be,da,joh,ke', | ||
'ius': 'cornel,dar,demetr,jul', | ||
'ley': 'brad,har,stan,wes', | ||
'mar': 'o,ou,am,la', | ||
'iel': 'gabr,dan,ar,nathan', | ||
'ane': 'souleym,d,du,sh', | ||
'ent': 'br,k,tr,vinc', | ||
'an': 'hass,ju,log,ary,roh,has,eit,yonat,ro,zor,drag,dej,stef,iv,emirh,ev,brend,d,jord,bry,de,esteb,ry,se,st,steph', | ||
'er': 'ik,javi,alexand,oliv,aleksand,om,christoph,kristoph,luth,elm,grov,hom,jasp,rodg,rog,spenc,tyl,xavi', | ||
'en': 'jayd,jad,aid,dev,eym,b,reub,rub,darr,lor,warr,all,dami,gl,k,ow,steph,stev', | ||
'in': 'yass,husse,benjam,mart,joaqu,hosse,col,frankl,marl,darw,edw,erw,dar,darr,efra,quent', | ||
'ie': 'j,jimm,samm,tomm,bill,charl,will,ern,arch,edd,frank,fredd,lou,regg,robb', | ||
'is': 'alex,lu,lou,math,chr,curt,den,denn,ell,franc,lew,morr,ot,trav,will', | ||
'el': 'abd,ang,no,jo,ro,ab,darr,fid,lion,marc,mich,russ', | ||
'ry': 'jer,per,ter,co,grego,ro,ga,zacha,hen,jeffe,jeff', | ||
'ce': 'lan,terran,van,bru,bry,hora,mauri,roy,walla', | ||
'ne': 'deway,dway,way,antoi,blai,jermai,euge,ge,tyro', | ||
'to': 'mina,yuu,haru,haruhi,haya,beni,ernes,ot', | ||
'or': 'heit,vict,ig,hect,juni,salvad,tayl,trev', | ||
'as': 'mati,tom,luc,thom,luk,tobi,jon,eli', | ||
'io': 'anton,emil,jul,rogel,gregor,ignac,mar,serg', | ||
'le': 'gabrie,doy,ky,ly,da,mer,orvil', | ||
'al': 'bil,,h,jam,miche,ne,rand', | ||
'dy': 'fred,ted,an,bra,co,gra,ru', | ||
'ad': 'muhamm,mohamm,moham,mur,br,ch,conr', | ||
'ey': 'dew,harv,jo,mick,rick,rodn,sidn', | ||
'am': 'li,willi,no,ad,abrah,grah,s', | ||
'ah': 'abdall,no,elij,jeremi,abdull,mic', | ||
'on': 'bry,j,jonath,le,marl,vern', | ||
'il': 'ne,nikh,cec,em,ph,virg', | ||
'im': 'j,t,ibrah,kar,hal,sel', | ||
'go': 'santia,thia,die,rodri,domin,hu', | ||
'ar': 'ces,hyd,aleksand,pet,edg,osc', | ||
'os': 'kiroll,carl,mil,am,marc,sant', | ||
'ro': 'ped,alejand,alessand,alva,artu,rami', | ||
'nd': 'arma,edmu,desmo,edmo,raymo', | ||
'ck': 'ja,chu,domini,ma,ni', | ||
'ta': 'hina,haru,sou,ara,kana', | ||
'ou': 'l,mamad,mahamad,sek,ry', | ||
'ph': 'ral,randol,rudol,jose,joes', | ||
'ik': 'er,adv,mal,min,sal', | ||
'rt': 'cu,ku,ba,stewa,stua', | ||
'us': 'mathe,jes,marc,ruf', | ||
'lo': 'ange,pab,abdul,nii', | ||
'es': 'jam,andr,charl,mos', | ||
'id': 'rach,dav,zah,shah', | ||
'nt': 'brya,cli,gra,lamo', | ||
're': 'and,pier,salvato,theodo', | ||
'ng': 'irvi,sterli,fe,yo', | ||
'ed': 'khal,,n,t', | ||
'ke': 'bla,ja,lu,mi', | ||
'th': 'hea,kei,kenne,se', | ||
'll': 'carro,kenda,marsha,randa', | ||
'di': 'fa,meh,mah,jor' | ||
}; | ||
arr = fns.uncompress_suffixes(arr, suffix_compressed); | ||
@@ -313,0 +314,0 @@ |
'use strict'; | ||
const buildResult = require('./result/build'); | ||
const pkg = require('../package.json'); | ||
//the main thing | ||
const nlp = function (str, context) { | ||
return buildResult(str, context); | ||
}; | ||
//this is handy | ||
nlp.version = pkg.version; | ||
module.exports = nlp; | ||
//and then all-the-exports... | ||
if (typeof self !== 'undefined') { | ||
self.nlp = nlp; // Web Worker | ||
} else if (typeof window !== 'undefined') { | ||
window.nlp = nlp; // Browser | ||
} else if (typeof global !== 'undefined') { | ||
global.nlp = nlp; // NodeJS | ||
} | ||
//don't forget amd! | ||
if (typeof define === 'function' && define.amd) { | ||
define(nlp); | ||
} | ||
//then for some reason, do this too! | ||
if (typeof module !== 'undefined') { | ||
module.exports = nlp; | ||
} |
@@ -30,2 +30,2 @@ :sparkles: :sparkles: hiiiii,:sparkles: :sparkles: | ||
[some help with contributing](https://github.com/nlp-compromise/nlp_compromise/wiki/Contributing) | ||
[some help with contributing](https://github.com/nlp-compromise/compromise/wiki/Contributing) |
@@ -15,3 +15,3 @@ 'use strict'; | ||
r.list.forEach((ts) => { | ||
ts.parent = r; | ||
ts.refText = r; | ||
}); | ||
@@ -18,0 +18,0 @@ r = corrections(r); |
'use strict'; | ||
const out = require('./methods/out'); | ||
//a Text is an array of termLists | ||
@@ -33,3 +34,5 @@ class Text { | ||
} | ||
out(msg, opts) { | ||
return out(this, msg, opts); | ||
} | ||
get whitespace() { | ||
@@ -60,11 +63,12 @@ return { | ||
Text = require('./methods/match/match')(Text); | ||
Text = require('./methods/render/render')(Text); | ||
Text = require('./methods/delete')(Text); | ||
Text = require('./methods/replace')(Text); | ||
Text = require('./methods/render/render')(Text); | ||
Text = require('./methods/split')(Text); | ||
Text = require('./methods/hyphens')(Text); | ||
Text = require('./methods/insert')(Text); | ||
Text.prototype.topk = require('./methods/render/topk'); | ||
Text.prototype.ngram = require('./methods/render/ngram'); | ||
// Text.prototype.topk = require('./methods/render/topk'); | ||
// Text.prototype.ngram = require('./methods/render/ngram'); | ||
Text.prototype.normalize = require('./methods/normalize'); | ||
// Text.prototype.out = | ||
@@ -77,3 +81,3 @@ const subset = { | ||
statements: require('./subset/sentences/statements'), | ||
things: require('./subset/things'), | ||
topics: require('./subset/topics'), | ||
terms: require('./subset/terms'), | ||
@@ -97,7 +101,7 @@ clauses: require('./subset/clauses'), | ||
Object.keys(subset).forEach((k) => { | ||
Text.prototype[k] = function () { | ||
Text.prototype[k] = function (num) { | ||
let sub = subset[k]; | ||
let m = sub.find(this); | ||
let m = sub.find(this, num); | ||
return new subset[k](m.list, this.lexicon, this.parent); | ||
}; | ||
}); |
@@ -25,3 +25,3 @@ 'use strict'; | ||
} | ||
return new Terms(arr, this.lexicon, this.parent); | ||
return new Terms(arr, this.lexicon, this.refText, this.refTerms); | ||
}); | ||
@@ -120,3 +120,3 @@ return new Text(list, this.lexicon, this.parent); | ||
} | ||
let ts = new Terms(terms, this.lexicon, this.parent); | ||
let ts = new Terms(terms, this.lexicon, this.refText, this.refTerms); | ||
return new Text([ts], this.lexicon, this.parent); | ||
@@ -123,0 +123,0 @@ }, |
'use strict'; | ||
//ngrams are consecutive terms of a specific size | ||
const ngram = function(options) { | ||
const ngram = function(r, options) { | ||
options = options || {}; | ||
@@ -10,3 +10,3 @@ options.size = options.size || [1, 2, 3]; | ||
//flatten terms | ||
let terms = this.list.map((ts) => { | ||
let terms = r.list.map((ts) => { | ||
return ts.mapTerms((t) => t.normal); | ||
@@ -13,0 +13,0 @@ }); |
@@ -47,28 +47,28 @@ 'use strict'; | ||
phrases: function () { | ||
this.list.forEach((ts) => { | ||
let str = ''; | ||
ts.terms.forEach((t) => { | ||
let text = t.plaintext(); | ||
if (t.tag.ConditionPhrase) { | ||
str += chalk.magenta(text); | ||
return; | ||
} | ||
if (t.tag.NounPhrase) { | ||
str += chalk.cyan(text); | ||
return; | ||
} | ||
if (t.tag.VerbPhrase) { | ||
str += chalk.red(text); | ||
return; | ||
} | ||
if (t.tag.AdjectivePhrase) { | ||
str += chalk.green(text); | ||
return; | ||
} | ||
str += text; | ||
}); | ||
console.log('\n' + str); | ||
}); | ||
}, | ||
// phrases: function () { | ||
// this.list.forEach((ts) => { | ||
// let str = ''; | ||
// ts.terms.forEach((t) => { | ||
// let text = t.plaintext(); | ||
// if (t.tag.ConditionPhrase) { | ||
// str += chalk.magenta(text); | ||
// return; | ||
// } | ||
// if (t.tag.NounPhrase) { | ||
// str += chalk.cyan(text); | ||
// return; | ||
// } | ||
// if (t.tag.VerbPhrase) { | ||
// str += chalk.red(text); | ||
// return; | ||
// } | ||
// if (t.tag.AdjectivePhrase) { | ||
// str += chalk.green(text); | ||
// return; | ||
// } | ||
// str += text; | ||
// }); | ||
// console.log('\n' + str); | ||
// }); | ||
// }, | ||
@@ -75,0 +75,0 @@ data: function() { |
@@ -24,3 +24,3 @@ 'use strict'; | ||
if (terms.length) { | ||
list.push(new Terms(terms, this.lexicon, this.parent)); | ||
list.push(new Terms(terms, this.lexicon, this.refText, this.refTerms)); | ||
} | ||
@@ -27,0 +27,0 @@ }); |
@@ -15,4 +15,8 @@ 'use strict'; | ||
} | ||
static find(r) { | ||
return r.match('#Acronym'); | ||
static find(r, n) { | ||
r = r.match('#Acronym'); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
return r; | ||
} | ||
@@ -19,0 +23,0 @@ } |
@@ -17,4 +17,8 @@ 'use strict'; | ||
} | ||
static find(r) { | ||
return r.match('#Adjective'); | ||
static find(r, n) { | ||
r = r.match('#Adjective'); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
return r; | ||
} | ||
@@ -21,0 +25,0 @@ } |
@@ -14,4 +14,8 @@ 'use strict'; | ||
} | ||
static find(r) { | ||
return r.match('#Adverb+'); | ||
static find(r, n) { | ||
r = r.match('#Adverb+'); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
return r; | ||
} | ||
@@ -18,0 +22,0 @@ } |
@@ -5,4 +5,7 @@ 'use strict'; | ||
class Clauses extends Text { | ||
static find(r) { | ||
static find(r, n) { | ||
r = r.splitAfter('#ClauseEnd'); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
return r; | ||
@@ -9,0 +12,0 @@ } |
@@ -30,7 +30,7 @@ 'use strict'; | ||
} | ||
static find(r) { | ||
static find(r, n) { | ||
//find currently-contracted | ||
let found = r.match('#Contraction #Contraction'); | ||
found.list = found.list.map((ts) => { | ||
let c = new Contraction(ts.terms, ts.lexicon, ts.parent, ts.parentTerms); | ||
let c = new Contraction(ts.terms, ts.lexicon, ts.refText, ts.refTerms); | ||
c.contracted = true; | ||
@@ -42,3 +42,3 @@ return c; | ||
expanded.list.forEach((ts) => { | ||
let c = new Contraction(ts.terms, ts.lexicon, ts.parent, ts.parentTerms); | ||
let c = new Contraction(ts.terms, ts.lexicon, ts.refText, ts.refTerms); | ||
c.contracted = false; | ||
@@ -48,2 +48,6 @@ found.list.push(c); | ||
found.sort('chronological'); | ||
//get nth element | ||
if (typeof n === 'number') { | ||
found = found.get(n); | ||
} | ||
return found; | ||
@@ -50,0 +54,0 @@ } |
@@ -9,4 +9,4 @@ 'use strict'; | ||
class Date extends Terms { | ||
constructor(arr, lexicon, parent) { | ||
super(arr, lexicon, parent); | ||
constructor(arr, lexicon, refText, refTerms) { | ||
super(arr, lexicon, refText, refTerms); | ||
this.month = this.match('#Month'); | ||
@@ -13,0 +13,0 @@ } |
@@ -27,6 +27,9 @@ 'use strict'; | ||
} | ||
static find(r) { | ||
static find(r, n) { | ||
let dates = r.match('#Date+'); | ||
if (typeof n === 'number') { | ||
dates = dates.get(n); | ||
} | ||
dates.list = dates.list.map((ts) => { | ||
return new Date(ts.terms, ts.lexicon, ts.parent, ts.parentTerms); | ||
return new Date(ts.terms, ts.lexicon, ts.refText, ts.refTerms); | ||
}); | ||
@@ -33,0 +36,0 @@ return dates; |
@@ -12,4 +12,8 @@ 'use strict'; | ||
} | ||
static find(r){ | ||
return r.match('#HashTag') | ||
static find(r, n) { | ||
r = r.match('#HashTag'); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
return r; | ||
} | ||
@@ -16,0 +20,0 @@ } |
@@ -11,10 +11,15 @@ 'use strict'; | ||
} | ||
static find(r) { | ||
r = r.splitAfter('#Comma'); | ||
static find(r, n) { | ||
r = r.clauses(); | ||
r = r.match('#Noun+'); | ||
r = r.not('#Pronoun'); | ||
// r = r.not('#Pronoun'); | ||
// if (r.match('#Date').found) { | ||
// r = r.not('#Date'); | ||
// } | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
r.list = r.list.map((ts) => { | ||
return new Noun(ts.terms, ts.lexicon, ts.parent, ts.parentTerms); | ||
return new Noun(ts.terms, ts.lexicon, ts.refText, ts.refTerms); | ||
}); | ||
// r = r.not('#Date'); | ||
return r; | ||
@@ -21,0 +26,0 @@ } |
@@ -5,4 +5,4 @@ 'use strict'; | ||
class Noun extends Terms { | ||
constructor(arr, lexicon, parent) { | ||
super(arr, lexicon, parent); | ||
constructor(arr, lexicon, refText, refTerms) { | ||
super(arr, lexicon, refText, refTerms); | ||
} | ||
@@ -9,0 +9,0 @@ data() { |
@@ -12,5 +12,9 @@ 'use strict'; | ||
} | ||
static find(r) { | ||
static find(r, n) { | ||
r = r.splitAfter('#Comma'); | ||
return r.match('#Organization+'); | ||
r = r.match('#Organization+'); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
return r; | ||
} | ||
@@ -17,0 +21,0 @@ } |
@@ -10,7 +10,10 @@ 'use strict'; | ||
} | ||
static find(r) { | ||
let people = r.splitAfter('#Comma'); | ||
static find(r, n) { | ||
let people = r.clauses(); | ||
people = people.match('#Person+'); | ||
if (typeof n === 'number') { | ||
people = people.get(n); | ||
} | ||
people.list = people.list.map((ts) => { | ||
return new Person(ts.terms, ts.lexicon, ts.parent, ts.parentTerms); | ||
return new Person(ts.terms, ts.lexicon, ts.refText, ts.refTerms); | ||
}); | ||
@@ -17,0 +20,0 @@ return people; |
@@ -7,4 +7,4 @@ 'use strict'; | ||
class Person extends Terms { | ||
constructor(arr, lexicon, parent) { | ||
super(arr, lexicon, parent); | ||
constructor(arr, lexicon, refText, refTerms) { | ||
super(arr, lexicon, refText, refTerms); | ||
this.firstName = this.match('#FirstName+'); | ||
@@ -11,0 +11,0 @@ this.middleName = this.match('#Acronym+'); |
@@ -14,3 +14,7 @@ 'use strict'; | ||
r = r.splitAfter('#Comma'); | ||
return r.match('#PhoneNumber+'); | ||
r = r.match('#PhoneNumber+'); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
return r; | ||
} | ||
@@ -17,0 +21,0 @@ } |
@@ -14,7 +14,10 @@ 'use strict'; | ||
} | ||
static find(r) { | ||
static find(r, n) { | ||
r = r.splitAfter('#Comma'); | ||
r = r.match('#Place+'); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
r.list = r.list.map((ts) => { | ||
return new Place(ts.terms, ts.lexicon, ts.parent, ts.parentTerms); | ||
return new Place(ts.terms, ts.lexicon, ts.refText, ts.refTerms); | ||
}); | ||
@@ -21,0 +24,0 @@ return r; |
@@ -5,4 +5,4 @@ 'use strict'; | ||
class Place extends Terms { | ||
constructor(arr, lexicon, parent) { | ||
super(arr, lexicon, parent); | ||
constructor(arr, lexicon, refText, refTerms) { | ||
super(arr, lexicon, refText, refTerms); | ||
this.city = this.match('#City'); | ||
@@ -9,0 +9,0 @@ this.country = this.match('#Country'); |
@@ -7,61 +7,54 @@ 'use strict'; | ||
class Sentences extends Text { | ||
data() { | ||
return this.list.map((ts) => { | ||
return { | ||
text: ts.plaintext(), | ||
normal: ts.normal() | ||
}; | ||
return ts.data(); | ||
}); | ||
} | ||
/** inflect the main/first noun*/ | ||
toSingular() { | ||
let nouns = this.match('#Noun').match('!#Pronoun').firstTerm(); | ||
nouns.things().toSingular(); | ||
/** conjugate the main/first verb*/ | ||
toPast() { | ||
return this; | ||
} | ||
toPlural() { | ||
let nouns = this.match('#Noun').match('!#Pronoun').firstTerm(); | ||
nouns.things().toPlural(); | ||
toPresent() { | ||
return this; | ||
} | ||
/** negate the main/first copula*/ | ||
toNegative() { | ||
let cp = this.match('#Copula'); | ||
if (cp.found) { | ||
cp.firstTerm().verbs().toNegative(); | ||
} else { | ||
this.match('#Verb').firstTerm().verbs().toNegative(); | ||
} | ||
toFuture() { | ||
return this; | ||
} | ||
toPositive() { | ||
this.match('#Negative').delete(); | ||
/** look for 'was _ by' patterns */ | ||
passive() { | ||
this.list = this.list.filter((ts) => { | ||
return ts.isPassive(); | ||
}); | ||
return this; | ||
} | ||
/** conjugate the main/first verb*/ | ||
toPast() { | ||
/** convert between question/statement/exclamation*/ | ||
toExclamation() { | ||
this.list.forEach((ts) => { | ||
ts.setPunctuation('!'); | ||
}); | ||
return this; | ||
} | ||
toPresent() { | ||
toQuestion() { | ||
this.list.forEach((ts) => { | ||
ts.setPunctuation('?'); | ||
}); | ||
return this; | ||
} | ||
toFuture() { | ||
toStatement() { | ||
this.list.forEach((ts) => { | ||
ts.setPunctuation('.'); | ||
}); | ||
return this; | ||
} | ||
/** look for 'was _ by' patterns */ | ||
isPassive() { | ||
//haha | ||
return this.match('was #Adverb? #PastTense #Adverb? by').found; | ||
} | ||
static find(r) { | ||
static find(r, n) { | ||
r = r.all(); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
r.list = r.list.map((ts) => { | ||
return new Sentence(ts.terms, ts.lexicon, ts.parent, ts.parentTerms); | ||
return new Sentence(ts.terms, ts.lexicon, ts.refText, ts.refTerms); | ||
}); | ||
return r; | ||
return new Text(r.list, this.lexicon, this.parent); | ||
} | ||
@@ -68,0 +61,0 @@ } |
@@ -5,15 +5,11 @@ 'use strict'; | ||
class Questions extends Text { | ||
data() { | ||
return this.list.map((ts) => { | ||
return { | ||
text: ts.plaintext(), | ||
normal: ts.normal() | ||
}; | ||
}); | ||
} | ||
static find(r) { | ||
static find(r, n) { | ||
r = r.all(); | ||
return r.filter((ts) => { | ||
r = r.filter((ts) => { | ||
return ts.last().endPunctuation() === '?'; | ||
}); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
return r; | ||
} | ||
@@ -20,0 +16,0 @@ } |
'use strict'; | ||
const Terms = require('../../paths').Terms; | ||
class Sentence extends Terms { | ||
data() { | ||
return { | ||
text: this.plaintext(), | ||
normal: this.normal() | ||
}; | ||
} | ||
/** inflect the main/first noun*/ | ||
toSingular() { | ||
let nouns = this.match('#Noun').match('!#Pronoun').firstTerm(); | ||
nouns.things().toSingular(); | ||
return this; | ||
} | ||
toPlural() { | ||
let nouns = this.match('#Noun').match('!#Pronoun').firstTerm(); | ||
nouns.things().toPlural(); | ||
return this; | ||
} | ||
/** negate the main/first copula*/ | ||
toNegative() { | ||
let cp = this.match('#Copula'); | ||
if (cp.found) { | ||
cp.firstTerm().verbs().toNegative(); | ||
} else { | ||
this.match('#Verb').firstTerm().verbs().toNegative(); | ||
} | ||
return this; | ||
} | ||
toPositive() { | ||
this.match('#Negative').first().delete(); | ||
return this; | ||
} | ||
setPunctuation(punct) { | ||
let last = this.terms[this.terms.length - 1]; | ||
last.setPunctuation(punct); | ||
} | ||
getPunctuation() { | ||
let last = this.terms[this.terms.length - 1]; | ||
return last.getPunctuation(); | ||
} | ||
/** look for 'was _ by' patterns */ | ||
isPassive() { | ||
//haha | ||
return this.match('was #Adverb? #PastTense #Adverb? by').found; | ||
} | ||
} | ||
module.exports = Sentence; |
@@ -5,11 +5,10 @@ 'use strict'; | ||
class Statements extends Text { | ||
data() { | ||
return this.mapTerms((t) => { | ||
return {}; | ||
}); | ||
} | ||
static find(r) { | ||
return r.filter((ts) => { | ||
static find(r, n) { | ||
r = r.filter((ts) => { | ||
return ts.last().endPunctuation() !== '?'; | ||
}); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
return r; | ||
} | ||
@@ -16,0 +15,0 @@ } |
@@ -28,5 +28,8 @@ 'use strict'; | ||
} | ||
static find(r) { | ||
let found = r.match('.'); | ||
return found; | ||
static find(r, n) { | ||
r = r.match('.'); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
return r; | ||
} | ||
@@ -33,0 +36,0 @@ } |
@@ -12,4 +12,8 @@ 'use strict'; | ||
} | ||
static find(r) { | ||
return r.match('#Url'); | ||
static find(r, n) { | ||
r = r.match('#Url'); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
return r; | ||
} | ||
@@ -16,0 +20,0 @@ } |
@@ -52,3 +52,3 @@ 'use strict'; | ||
} | ||
static find(r) { | ||
static find(r, n) { | ||
r = r.match('#Value+'); | ||
@@ -58,4 +58,7 @@ if (r.has('. (a|an)')) { | ||
} | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
r.list = r.list.map((ts) => { | ||
return new Value(ts.terms, ts.lexicon, ts.parent, ts.parentTerms); | ||
return new Value(ts.terms, ts.lexicon, ts.refText, ts.refTerms); | ||
}); | ||
@@ -62,0 +65,0 @@ return r; |
@@ -139,4 +139,4 @@ 'use strict'; | ||
}); | ||
return new Value(terms, this.lexicon, this.parent, this.parentTerms); | ||
return new Value(terms, this.lexicon, this.refText, this.refTerms); | ||
}; | ||
module.exports = Value; |
@@ -63,4 +63,8 @@ 'use strict'; | ||
} | ||
static find(r) { | ||
return r.match('#Verb+'); | ||
static find(r, n) { | ||
r = r.match('#Verb+'); | ||
if (typeof n === 'number') { | ||
r = r.get(n); | ||
} | ||
return r; | ||
} | ||
@@ -67,0 +71,0 @@ } |
@@ -38,5 +38,2 @@ 'use strict'; | ||
is = is.slice(0); //clone it | ||
if (extra[k]) { | ||
is.push(extra[k]); | ||
} | ||
all[k] = { | ||
@@ -53,2 +50,9 @@ parents: is, | ||
//add extras | ||
Object.keys(all).forEach((tag) => { | ||
if (extra[tag]) { | ||
all[tag].parents.push(extra[tag]); | ||
} | ||
}); | ||
//add conflicts | ||
@@ -65,3 +69,3 @@ Object.keys(all).forEach((tag) => { | ||
module.exports = all; | ||
// console.log(all.Month); | ||
// console.log(all.Duration); | ||
// console.log(all_children(tree['NounPhrase'])); |
@@ -62,3 +62,26 @@ 'use strict'; | ||
} | ||
/** the punctuation at the end of this term*/ | ||
endPunctuation() { | ||
let m = this.text.match(/[a-z]([,:;\/.(\.\.\.)\!\?]+)$/i); | ||
if (m) { | ||
const allowed = { | ||
',': 'comma', | ||
':': 'colon', | ||
';': 'semicolon', | ||
'.': 'period', | ||
'...': 'elipses', | ||
'!': 'exclamation', | ||
'?': 'question' | ||
}; | ||
if (allowed[m[1]]) { | ||
return m[1]; | ||
} | ||
} | ||
return null; | ||
} | ||
setPunctuation(punct) { | ||
this.text = this.text.replace(/[a-z]([,:;\/.(\.\.\.)\!\?]+)$/i, ''); | ||
this.text += punct; | ||
return this; | ||
} | ||
normalize() { | ||
@@ -69,12 +92,12 @@ addNormal(this); | ||
/** the comma, period ... punctuation that ends this sentence */ | ||
endPunctuation() { | ||
let m = this._text.match(/([\.\?\!,;:])$/); | ||
if (m) { | ||
//remove it from end of text | ||
// this.text = this._text.substr(0, this._text.length - 1); | ||
return m[0]; | ||
} | ||
return ''; | ||
} | ||
// /** the comma, period ... punctuation that ends this sentence */ | ||
// endPunctuation() { | ||
// let m = this._text.match(/([\.\?\!,;:])$/); | ||
// if (m) { | ||
// //remove it from end of text | ||
// // this.text = this._text.substr(0, this._text.length - 1); | ||
// return m[0]; | ||
// } | ||
// return ''; | ||
// } | ||
@@ -81,0 +104,0 @@ /** print-out this text, as it was given */ |
@@ -47,4 +47,4 @@ 'use strict'; | ||
word = '\'' + chalk.green(word || '-') + '\''; | ||
if(this.dirty){ | ||
word+='*' | ||
if (this.dirty) { | ||
word += '*'; | ||
} | ||
@@ -57,3 +57,3 @@ let silent = ''; | ||
word = fns.leftPad(word, 25); | ||
word += fns.leftPad(silent, 10); | ||
word += fns.leftPad(silent, 1); | ||
// word = fns.leftPad(word, 32); | ||
@@ -60,0 +60,0 @@ // word = fns.rightPad(word, 28); |
@@ -41,3 +41,3 @@ 'use strict'; | ||
return html.replace(/</g, '<'); | ||
} | ||
}; | ||
@@ -47,10 +47,10 @@ //turn the term into ~properly~ formatted html | ||
let classes = Object.keys(t.tag).filter((tag) => tag !== 'Term'); | ||
classes = classes.map(c => 'nlp' + c); | ||
classes = classes.map(c => 'nl-' + c); | ||
classes = classes.join(' '); | ||
let text = sanitize(t.text) | ||
let text = sanitize(t.text); | ||
text = escapeHtml(text); | ||
let el = '<span class="' + classes + '">' + text + '</span>'; | ||
return escapeHtml(t.whitespace.before) + el + escapeHtml(t.whitespace.after) | ||
return escapeHtml(t.whitespace.before) + el + escapeHtml(t.whitespace.after); | ||
}; | ||
module.exports = renderHtml; |
@@ -8,22 +8,2 @@ 'use strict'; | ||
/** the punctuation at the end of this term*/ | ||
endPunctuation: function () { | ||
let m = this.text.match(/[a-z]([,:;\/.(\.\.\.)\!\?]+)$/i); | ||
if (m) { | ||
const allowed = { | ||
',': 'comma', | ||
':': 'colon', | ||
';': 'semicolon', | ||
'.': 'period', | ||
'...': 'elipses', | ||
'!': 'exclamation', | ||
'?': 'question' | ||
}; | ||
if (allowed[m[1]]) { | ||
return allowed[m[1]]; | ||
} | ||
} | ||
return null; | ||
}, | ||
/** interpret a term's hyphenation */ | ||
@@ -166,7 +146,2 @@ hyphenation: function () { | ||
return true; | ||
}, | ||
insertAfter: function () { | ||
let index = this.index(); | ||
// console.log(this.parent) | ||
} | ||
@@ -173,0 +148,0 @@ |
@@ -10,3 +10,3 @@ 'use strict'; | ||
this.refText = refText; | ||
this.refTerms = refTerms; | ||
this._refTerms = refTerms; | ||
this.get = (n) => { | ||
@@ -25,2 +25,9 @@ return this.terms[n]; | ||
} | ||
get refTerms() { | ||
return this._refTerms || this; | ||
} | ||
set refTerms(ts) { | ||
this._refTerms = ts; | ||
return this; | ||
} | ||
set dirty(dirt) { | ||
@@ -27,0 +34,0 @@ this.terms.forEach((t) => { |
@@ -29,3 +29,3 @@ 'use strict'; | ||
matches = matches.map((a) => { | ||
return new Terms(a, this.lexicon, this.parent, this.parentTerms); | ||
return new Terms(a, this.lexicon, this.refText, this.refTerms); | ||
}); | ||
@@ -94,3 +94,3 @@ // return matches | ||
matches = matches.map((a) => { | ||
return new Terms(a, this.lexicon, this.parent, this.parentTerms); | ||
return new Terms(a, this.lexicon, this.refText, this.refTerms); | ||
}); | ||
@@ -97,0 +97,0 @@ } |
@@ -11,8 +11,12 @@ 'use strict'; | ||
let t = this.terms[0]; | ||
return new Terms([t], this.lexicon, this.parent); | ||
return new Terms([t], this.lexicon, this.refText, this.refTerms); | ||
}, | ||
last: function () { | ||
let t = this.terms[this.terms.length - 1]; | ||
return new Terms([t], this.lexicon, this.parent); | ||
return new Terms([t], this.lexicon, this.refText, this.refTerms); | ||
}, | ||
slice: function (start, end) { | ||
let terms = this.terms.slice(start, end); | ||
return new Terms(terms, this.lexicon, this.refText, this.refTerms); | ||
}, | ||
endPunctuation: function () { | ||
@@ -47,3 +51,3 @@ return this.last().terms[0].endPunctuation(); | ||
let first = this.terms[0]; | ||
let ref = this.parent; | ||
let ref = this.refText || this; | ||
if (!ref || !first) { | ||
@@ -50,0 +54,0 @@ return null; //maybe.. |
@@ -15,5 +15,12 @@ 'use strict'; | ||
normal: function () { | ||
return this.terms.filter((t) => t.text).map((t) => t.normal).join(' '); | ||
let terms = this.terms.filter((t) => { | ||
return t.text; | ||
}); | ||
terms = terms.map((t) => { | ||
return t.normal; //+ punct; | ||
}); | ||
return terms.join(' '); | ||
}, | ||
/** no punctuation, fancy business **/ | ||
root: function () { | ||
@@ -20,0 +27,0 @@ return this.terms.filter((t) => t.text).map((t) => t.normal).join(' ').toLowerCase(); |
@@ -42,3 +42,6 @@ 'use strict'; | ||
//make them termlists | ||
all = all.map((ts) => new Terms(ts, ts.lexicon, ts.parent)); | ||
all = all.map((ts) => { | ||
let parent = this.refText; //|| this; | ||
return new Terms(ts, ts.lexicon, parent, ts.refTerms); | ||
}); | ||
return all; | ||
@@ -65,3 +68,3 @@ }, | ||
all = all.filter(a => a && a.length); | ||
all = all.map((ts) => new Terms(ts, ts.lexicon, ts.parent)); | ||
all = all.map((ts) => new Terms(ts, ts.lexicon, ts.refText, this.refTerms)); | ||
return all; | ||
@@ -102,3 +105,3 @@ }, | ||
all = all.filter(a => a && a.length); | ||
all = all.map((ts) => new Terms(ts, ts.lexicon, ts.parent)); | ||
all = all.map((ts) => new Terms(ts, ts.lexicon, ts.refText, this.refTerms)); | ||
return all; | ||
@@ -105,0 +108,0 @@ }, |
@@ -17,3 +17,3 @@ 'use strict'; | ||
}); | ||
return new Terms(terms, this.lexicon, this.parent); | ||
return new Terms(terms, this.lexicon, this.refText, this.refTerms); | ||
}, | ||
@@ -20,0 +20,0 @@ hyphenate: function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
975953
237
27191
31