',0)->delete(); #载入纸质词典数据 $paper = UserDict::selectRaw('word,count(*)')->where("source",'_PAPER_')->groupBy('word')->cursor(); $sql = "select count(*) from ( select word, count(*) from user_dicts ud where source = '_PAPER_' group by word) as T"; $count = DB::select($sql); $bar = $this->output->createProgressBar($count[0]->count); foreach ($paper as $key => $word) { $newWord = new WordPart; $newWord->word = $word->word; $newWord->weight = $word->count; $newWord->save(); $bar->advance(); } $bar->finish(); #载入csv数据 $csvFile = config("mint.path.dict_text") .'/system/part2.csv'; if (($fp = fopen($csvFile, "r")) !== false) { Log::info("csv load:" . $csvFile); while (($data = fgetcsv($fp, 0, ',')) !== false) { WordPart::updateOrCreate(['word' => $data[0],],['weight' => $data[1],]); } fclose($fp); } else { $this->error( "can not open csv file. filename=" . $csvFile. PHP_EOL) ; Log::error( "can not open csv file. filename=" . $csvFile) ; } $this->info('ok'); return 0; } }