//phrasal verbs are two words that really mean one verb.
//'beef up' is one verb, and not some direction of beefing.
//by @spencermountain, 2015 mit
//many credits to http://www.allmyphrasalverbs.com/
var verb_conjugate = require("../../parents/verb/conjugate/conjugate")

//start the list with some randoms
var main = [
  "be onto",
  "fall behind",
  "fall through",
  "fool with",
  "get across",
  "get along",
  "get at",
  "give way",
  "hear from",
  "hear of",
  "lash into",
  "make do",
  "run across",
  "set upon",
  "take aback",
  "keep from"
]

//if there's a phrasal verb "keep on", there's often a "keep off"
var opposites = {
  "away": "back",
  "in": "out",
  "on": "off",
  "over": "under",
  "together": "apart",
  "up": "down"
}

//forms that have in/out symmetry
var symmetric = {
  "away": "blow,bounce,bring,call,come,cut,drop,fire,get,give,go,keep,pass,put,run,send,shoot,switch,take,tie,throw",
  "in": "bang,barge,bash,beat,block,book,box,break,bring,burn,butt,carve,cash,check,come,cross,drop,fall,fence,fill,give,grow,hand,hang,head,jack,keep,leave,let,lock,log,move,opt,pack,peel,pull,put,rain,reach,ring,rub,send,set,settle,shut,sign,smash,snow,strike,take,try,turn,type,warm,wave,wean,wear,wheel",
  "on": "add,call,carry,catch,count,feed,get,give,go,grind,head,hold,keep,lay,log,pass,pop,power,put,send,show,snap,switch,take,tell,try,turn,wait",
  "over": "come,go,look,read,run,talk",
  "together": "come,pull,put",
  "up": "add,back,beat,bend,blow,boil,bottle,break,bring,buckle,bundle,call,carve,clean,cut,dress,fill,flag,fold,get,give,grind,grow,hang,hold,keep,let,load,lock,look,man,mark,melt,move,pack,pin,pipe,plump,pop,power,pull,put,rub,scale,scrape,send,set,settle,shake,show,sit,slow,smash,square,stand,strike,take,tear,tie,turn,use,wash,wind",
}
Object.keys(symmetric).forEach(function (k) {
  symmetric[k].split(',').forEach(function (s) {
    //add the given form
    main.push(s + " " + k)
    //add its opposite form
    main.push(s + " " + opposites[k])
  })
})

//forms that don't have in/out symmetry
var asymmetric = {
  "about": "bring,fool,gad,go,root",
  "after": "go,look,take",
  "ahead": "get,go,press",
  "along": "bring,move",
  "apart": "fall,take",
  "around": "ask,boss,bring,call,come,fool,get,horse,joke,lie,mess,play",
  "away": "back,carry,file,frighten,hide,wash",
  "back": "fall,fight,hit,hold,look,pay,stand,think",
  "by": "drop,get,go,stop,swear,swing,tick,zip",
  "down": "bog,calm,fall,hand,hunker,jot,knock,lie,narrow,note,pat,pour,run,tone,trickle,wear",
  "for": "fend,file,gun,hanker,root,shoot",
  "forth": "bring,come",
  "forward": "come,look",
  "in": "cave,chip,hone,jump,key,pencil,plug,rein,shade,sleep,stop,suck,tie,trade,tuck,usher,weigh,zero",
  "into": "look,run",
  "it": "go,have",
  "off": "auction,be,beat,blast,block,brush,burn,buzz,cast,cool,drop,end,face,fall,fend,frighten,goof,jack,kick,knock,laugh,level,live,make,mouth,nod,pair,pay,peel,read,reel,ring,rip,round,sail,shave,shoot,sleep,slice,split,square,stave,stop,storm,strike,tear,tee,tick,tip,top,walk,work,write",
  "on": "bank,bargain,egg,frown,hit,latch,pile,prattle,press,spring,spur,tack,urge,yammer",
  "out": "act,ask,back,bail,bear,black,blank,bleed,blow,blurt,branch,buy,cancel,cut,eat,edge,farm,figure,find,fill,find,fish,fizzle,flake,flame,flare,flesh,flip,geek,get,help,hide,hold,iron,knock,lash,level,listen,lose,luck,make,max,miss,nerd,pan,pass,pick,pig,point,print,psych,rat,read,rent,root,rule,run,scout,see,sell,shout,single,sit,smoke,sort,spell,splash,stamp,start,storm,straighten,suss,time,tire,top,trip,trot,wash,watch,weird,whip,wimp,wipe,work,zone,zonk",
  "over": "bend,bubble,do,fall,get,gloss,hold,keel,mull,pore,sleep,spill,think,tide,tip",
  "round": "get,go",
  "through": "go,run",
  "to": "keep,see",
  "up": "act,beef,board,bone,boot,brighten,build,buy,catch,cheer,cook,end,eye,face,fatten,feel,fess,finish,fire,firm,flame,flare,free,freeze,freshen,fry,fuel,gang,gear,goof,hack,ham,heat,hit,hole,hush,jazz,juice,lap,light,lighten,line,link,listen,live,loosen,make,mash,measure,mess,mix,mock,mop,muddle,open,own,pair,patch,pick,prop,psych,read,rough,rustle,save,shack,sign,size,slice,slip,snap,sober,spark,split,spruce,stack,start,stay,stir,stitch,straighten,string,suck,suit,sum,team,tee,think,tidy,tighten,toss,trade,trip,type,vacuum,wait,wake,warm,weigh,whip,wire,wise,word,write,zip",
}
Object.keys(asymmetric).forEach(function (k) {
  asymmetric[k].split(',').forEach(function (s) {
    main.push(s + " " + k)
  })
})

//at his point all verbs are infinitive. lets make this explicit.
main = main.reduce(function (h, s) {
  h[s] = "VBP"
  return h
}, {})

//conjugate every phrasal verb. takes ~30ms
var tags = {
  present: "VB",
  past: "VBD",
  future: "VBF",
  gerund: "VBG",
  infinitive: "VBP",
}
var cache = {} //cache individual verbs to speed it up
var split, verb, particle, phrasal;
Object.keys(main).forEach(function (s) {
  split = s.split(' ')
  verb = split[0]
  particle = split[1]
  if (cache[verb] === undefined) {
    cache[verb] = verb_conjugate(verb)
  }
  Object.keys(cache[verb]).forEach(function (k) {
    phrasal = cache[verb][k] + " " + particle
    main[phrasal] = tags[k]
  })
})

module.exports = main;
// console.log(JSON.stringify(phrasal_verbs, null, 2))
