//command line argumentsvarargv=process.argv.splice(2);(function(){if(argv.length==0||argv.length>2){usage();process.exit(1);}elseif(argv.length==1){word=argv[0];}else{varswt=argv[0];word=argv[1];if(swt.search(/e|E/)!=-1){ee=true;}if(swt.search(/p|P/)!=-1){pnc=true;}if(swt.search(/v/)!=-1){ee=cc=true;}if(swt.search(/V/)!=-1){pnc=true;ee=cc=true;}}})();
functiongenOutput(xml){varres=[];xmlreader.read(xml,function(err,response){if(err)returnconsole.log(err);varbasic=response.yodaodict.basic;if(!basic)return;for(vari=0;i<basic.count();i++){varexpand=false;//english chinese --defaultvartype=basic.at(i).type.text().toLowerCase();if((type==='ec'&&cc)||(type==='ee'&&ee)||(type==='ce'&&cc)){res.push({type:basic.at(i).name.text(),word:[]});expand=true;}if(expand){//console.log(res[res.length - 1].type);varxword=basic.at(i)['authoritative-dict'].word;if(!xword)continue;varword=res[res.length-1].word;for(varword_c=0;word_c<xword.count();word_c++){word.push({type:'',trs:[]});varxtrs=xword.at(word_c).trs;if(!xtrs)continue;vartrs=word[word.length-1].trs;trs.push({type:'',exp:[]});varexp=trs[trs.length-1].exp;for(vartrs_c=0;trs_c<xtrs.count();trs_c++){if(xtrs.at(trs_c).pos){trs[trs.length-1].type=xtrs.at(trs_c).pos.text();}varxtr=xtrs.at(trs_c).tr;if(!xtr)continue;for(vartr_c=0;tr_c<xtr.count();tr_c++){try{exp.push(xtr.at(tr_c).l.i.text());}catch(e){}}}}}else{//console.log(basic.at(i).name.text());}}});returnres;}