瀏覽代碼

:sparkles: 拆分意思

visuddhinanda 2 年之前
父節點
當前提交
ba22b7541b
共有 1 個文件被更改,包括 16 次插入2 次删除
  1. 16 2
      app/Console/Commands/UpgradeWbwAnalyses.php

+ 16 - 2
app/Console/Commands/UpgradeWbwAnalyses.php

@@ -50,7 +50,7 @@ class UpgradeWbwAnalyses extends Command
         }else{
             $it = Wbw::where('id',$this->argument('id'))->orderby('id')->cursor();
         }
-        
+
         foreach ($it as $wbwrow) {
             $counter++;
             WbwAnalysis::where('wbw_id',$wbwrow->id)->delete();
@@ -64,10 +64,11 @@ class UpgradeWbwAnalyses extends Command
             }catch(Exception $e){
                 continue;
             }
-            
+
             $wordsList = $xmlWord->xpath('//word');
             foreach ($wordsList as $word) {
                 $pali = $word->real->__toString();
+                $factors = [];
                 foreach ($word as $key => $value) {
                     $strValue = $value->__toString();
                     if ($strValue !== "?" && $strValue !== "" && $strValue !== ".ctl." && $strValue !== ".a." && $strValue !== " " && mb_substr($strValue, 0, 3, "UTF-8") !== "[a]" && $strValue !== "_un_auto_factormean_" && $strValue !== "_un_auto_mean_") {
@@ -104,10 +105,23 @@ class UpgradeWbwAnalyses extends Command
                             case 'org':
                                 $newData['type']=4;
                                 WbwAnalysis::insert($newData);
+                                $factors=explode("+",$strValue);
                                 break;
                             case 'om':
                                 $newData['type']=5;
                                 WbwAnalysis::insert($newData);
+                                # 存储拆分意思
+                                $newData['type']=7;
+                                $factorMeaning = explode('+',$strValue);
+                                foreach ( $factors as $index => $factor) {
+                                    if(isset($factorMeaning[$index]) &&
+                                      !empty($factorMeaning[$index]) &&
+                                      $factorMeaning[$index] !== "↓↓" ){
+                                        $newData['wbw_word'] = $factor;
+                                        $newData['data'] = $factorMeaning[$index];
+                                        WbwAnalysis::insert($newData);
+                                    }
+                                }
                                 break;
                             case 'parent':
                                 $newData['type']=6;