argument('book'); $para = $this->argument('para'); for ($iBook=1; $iBook <= 217 ; $iBook++) { if($book && $book != $iBook ){ continue; } $this->info('running book='.$iBook); $maxPara = WbwTemplate::where("book",$iBook)->max('paragraph'); $bar = $this->output->createProgressBar($maxPara); for ($iPara=1; $iPara <= $maxPara ; $iPara++) { if($para && $para != $iPara ){ continue; } $bar->advance(); $words = WbwTemplate::where("book",$iBook) ->where("paragraph",$iPara) ->orderBy('wid','asc') ->get(); $start = -1; $bold = 0; for ($iWord=0; $iWord < count($words); $iWord++) { WbwTemplate::where('id',$words[$iWord]->id)->update(['weight'=>1]); if($words[$iWord]->style === 'bld'){ if($start === -1){ $start = $iWord; $bold = 1; }else{ $bold++; } }else{ if($start>=0){ $weight = 10 / pow($bold,2); for ($i=$start; $i < $iWord ; $i++) { $wordWeight = 1 + $weight; $result = WbwTemplate::where('id',$words[$i]->id) ->update(['weight'=>(int)$wordWeight]); } $start = -1; $bold = 0; } } } } $bar->finish(); } return 0; } }