fukuball / jieba-php

@@ -195,7 +195,7 @@
Loading
195 195
     */
196 196
    public static function loadUserDict($f_name, $options = array())
197 197
    {
198 -
        array_push(self::$user_dictname, $f_name);
198 +
        self::$user_dictname[] = $f_name;
199 199
        $content = fopen($f_name, "r");
200 200
        while (($line = fgets($content)) !== false) {
201 201
            $explode_line = explode(" ", trim($line));
@@ -212,7 +212,7 @@
Loading
212 212
            $word_c = array();
213 213
            for ($i=0; $i<$l; $i++) {
214 214
                $c = mb_substr($word, $i, 1, 'UTF-8');
215 -
                array_push($word_c, $c);
215 +
                $word_c[] = $c;
216 216
            }
217 217
            $word_c_key = implode('.', $word_c);
218 218
            self::$trie->set($word_c_key, array("end"=>""));
@@ -244,7 +244,7 @@
Loading
244 244
        $word_c = array();
245 245
        for ($i=0; $i<$l; $i++) {
246 246
            $c = mb_substr($word, $i, 1, 'UTF-8');
247 -
            array_push($word_c, $c);
247 +
            $word_c[] = $c;
248 248
        }
249 249
        $word_c_key = implode('.', $word_c);
250 250
        self::$trie->set($word_c_key, array("end"=>""));
@@ -274,7 +274,7 @@
Loading
274 274
                'end' => $end
275 275
            ];
276 276
            $start = $end;
277 -
            array_push($tokenize_list, $tokenize);
277 +
            $tokenize_list[] = $tokenize;
278 278
        }
279 279
        return $tokenize_list;
280 280
    }
@@ -303,13 +303,13 @@
Loading
303 303
        foreach ($DAG as $k => $L) {
304 304
            if (count($L) == 1 && $k > $old_j) {
305 305
                $word = mb_substr($sentence, $k, (($L[0]-$k)+1), 'UTF-8');
306 -
                array_push($words, $word);
306 +
                $words[] = $word;
307 307
                $old_j = $L[0];
308 308
            } else {
309 309
                foreach ($L as $j) {
310 310
                    if ($j > $k) {
311 311
                        $word = mb_substr($sentence, $k, ($j-$k)+1, 'UTF-8');
312 -
                        array_push($words, $word);
312 +
                        $words[] = $word;
313 313
                        $old_j = $j;
314 314
                    }
315 315
                }
@@ -351,12 +351,12 @@
Loading
351 351
352 352
            if (isset(self::$dag_cache[$next_word_key])) {
353 353
                if (self::$dag_cache[$next_word_key]['exist']) {
354 -
                    array_push($word_c, $c);
354 +
                    $word_c[] = $c;
355 355
                    if (self::$dag_cache[$next_word_key]['end']) {
356 356
                        if (!isset($DAG[$i])) {
357 357
                            $DAG[$i] = array();
358 358
                        }
359 -
                        array_push($DAG[$i], $j);
359 +
                        $DAG[$i][] = $j;
360 360
                    }
361 361
                    $j += 1;
362 362
                    if ($j >= $N) {
@@ -374,7 +374,7 @@
Loading
374 374
375 375
            if (self::$trie->exists($next_word_key)) {
376 376
                self::$dag_cache[$next_word_key] = array('exist' => true, 'end' => false);
377 -
                array_push($word_c, $c);
377 +
                $word_c[] = $c;
378 378
                $next_word_key_value = self::$trie->get($next_word_key);
379 379
                if ($next_word_key_value == array("end"=>"")
380 380
                 || isset($next_word_key_value["end"])
@@ -384,7 +384,7 @@
Loading
384 384
                    if (!isset($DAG[$i])) {
385 385
                        $DAG[$i] = array();
386 386
                    }
387 -
                    array_push($DAG[$i], $j);
387 +
                    $DAG[$i][] = $j;
388 388
                }
389 389
                $j += 1;
390 390
                if ($j >= $N) {
@@ -445,41 +445,41 @@
Loading
445 445
            } else {
446 446
                if (mb_strlen($buf, 'UTF-8')>0) {
447 447
                    if (mb_strlen($buf, 'UTF-8')==1) {
448 -
                        array_push($words, $buf);
448 +
                        $words[] = $buf;
449 449
                        $buf = '';
450 450
                    } else {
451 451
                        if (! isset(self::$FREQ[$buf])) {
452 452
                            $regognized = Finalseg::cut($buf);
453 453
                            foreach ($regognized as $key => $word) {
454 -
                                array_push($words, $word);
454 +
                                $words[] = $word;
455 455
                            }
456 456
                        } else {
457 457
                            $elem_array = preg_split('//u', $buf, -1, PREG_SPLIT_NO_EMPTY);
458 458
                            foreach ($elem_array as $word) {
459 -
                                array_push($words, $word);
459 +
                                $words[] = $word;
460 460
                            }
461 461
                        }
462 462
                        $buf = '';
463 463
                    }
464 464
                }
465 -
                array_push($words, $l_word);
465 +
                $words[] = $l_word;
466 466
            }
467 467
            $x = $y;
468 468
        }
469 469
470 470
        if (mb_strlen($buf, 'UTF-8')>0) {
471 471
            if (mb_strlen($buf, 'UTF-8')==1) {
472 -
                array_push($words, $buf);
472 +
                $words[] = $buf;
473 473
            } else {
474 474
                if (! isset(self::$FREQ[$buf])) {
475 475
                    $regognized = Finalseg::cut($buf);
476 476
                    foreach ($regognized as $key => $word) {
477 -
                        array_push($words, $word);
477 +
                        $words[] = $word;
478 478
                    }
479 479
                } else {
480 480
                    $elem_array = preg_split('//u', $buf, -1, PREG_SPLIT_NO_EMPTY);
481 481
                    foreach ($elem_array as $word) {
482 -
                        array_push($words, $word);
482 +
                        $words[] = $word;
483 483
                    }
484 484
                }
485 485
            }
@@ -526,16 +526,16 @@
Loading
526 526
                $x = $y;
527 527
            } else {
528 528
                if (mb_strlen($buf, 'UTF-8')>0) {
529 -
                    array_push($words, $buf);
529 +
                    $words[] = $buf;
530 530
                    $buf = '';
531 531
                }
532 -
                array_push($words, $l_word);
532 +
                $words[] = $l_word;
533 533
                $x = $y;
534 534
            }
535 535
        }
536 536
537 537
        if (mb_strlen($buf, 'UTF-8')>0) {
538 -
            array_push($words, $buf);
538 +
            $words[] = $buf;
539 539
            $buf = '';
540 540
        }
541 541
@@ -614,7 +614,7 @@
Loading
614 614
                }
615 615
616 616
                foreach ($words as $word) {
617 -
                    array_push($seg_list, $word);
617 +
                    $seg_list[] = $word;
618 618
                }
619 619
            } elseif (preg_match('/'.$re_skip_pattern.'/u', $blk)) {
620 620
                preg_match_all(
@@ -627,21 +627,21 @@
Loading
627 627
                foreach ($tmp as $x) {
628 628
                    if (preg_match('/'.$re_skip_pattern.'/u', $x)) {
629 629
                        if (str_replace(' ', '', $x) != '') {
630 -
                            array_push($seg_list, $x);
630 +
                            $seg_list[] = $x;
631 631
                        }
632 632
                    } else {
633 633
                        if (!$cut_all) {
634 634
                            $xx_array = preg_split('//u', $x, -1, PREG_SPLIT_NO_EMPTY);
635 635
                            foreach ($xx_array as $xx) {
636 -
                                array_push($seg_list, $xx);
636 +
                                $seg_list[] = $xx;
637 637
                            }
638 638
                        } else {
639 -
                            array_push($seg_list, $x);
639 +
                            $seg_list[] = $x;
640 640
                        }
641 641
                    }
642 642
                }
643 643
            } elseif (preg_match('/'.$re_punctuation_pattern.'/u', $blk)) {
644 -
                array_push($seg_list, $blk);
644 +
                $seg_list[] = $blk;
645 645
            }// end else (preg_match('/'.$re_han_pattern.'/u', $blk))
646 646
        }// end foreach ($blocks as $blk)
647 647
@@ -676,7 +676,7 @@
Loading
676 676
                    $gram2 = mb_substr($w, $i, 2, 'UTF-8');
677 677
678 678
                    if (isset(self::$FREQ[$gram2])) {
679 -
                        array_push($seg_list, $gram2);
679 +
                        $seg_list[] = $gram2;
680 680
                    }
681 681
                }
682 682
            }
@@ -686,12 +686,12 @@
Loading
686 686
                    $gram3 = mb_substr($w, $i, 3, 'UTF-8');
687 687
688 688
                    if (isset(self::$FREQ[$gram3])) {
689 -
                        array_push($seg_list, $gram3);
689 +
                        $seg_list[] = $gram3;
690 690
                    }
691 691
                }
692 692
            }
693 693
694 -
            array_push($seg_list, $w);
694 +
            $seg_list[] = $w;
695 695
        }
696 696
697 697
        return $seg_list;

@@ -53,10 +53,10 @@
Loading
53 53
        self::$prob_emit = self::loadModel(dirname(dirname(__FILE__)).'/model/pos/prob_emit.json');
54 54
        self::$char_state = self::loadModel(dirname(dirname(__FILE__)).'/model/pos/char_state.json');
55 55
56 -
        if (Jieba::$dictname!="") {
57 -
            $content = fopen(dirname(dirname(__FILE__))."/dict/".Jieba::$dictname, "r");
56 +
        if (Jieba::$dictname!='') {
57 +
            $content = fopen(dirname(dirname(__FILE__)).'/dict/'.Jieba::$dictname, 'r');
58 58
            while (($line = fgets($content)) !== false) {
59 -
                $explode_line = explode(" ", trim($line));
59 +
                $explode_line = explode(' ', trim($line));
60 60
                $word = $explode_line[0];
61 61
                $freq = $explode_line[1];
62 62
                $tag = $explode_line[2];
@@ -68,9 +68,9 @@
Loading
68 68
69 69
        if (sizeof(Jieba::$user_dictname)!=0) {
70 70
            for ($i = 0; $i<sizeof(Jieba::$user_dictname); $i++) {
71 -
                $content = fopen(Jieba::$user_dictname[$i], "r");
71 +
                $content = fopen(Jieba::$user_dictname[$i], 'r');
72 72
                while (($line = fgets($content)) !== false) {
73 -
                    $explode_line = explode(" ", trim($line));
73 +
                    $explode_line = explode(' ', trim($line));
74 74
                    $word = $explode_line[0];
75 75
                    $freq = $explode_line[1];
76 76
                    $tag = $explode_line[2];
@@ -80,10 +80,10 @@
Loading
80 80
            }
81 81
        }
82 82
83 -
        $content = fopen(dirname(dirname(__FILE__))."/dict/pos_tag_readable.txt", "r");
83 +
        $content = fopen(dirname(dirname(__FILE__)).'/dict/pos_tag_readable.txt', 'r');
84 84
85 85
        while (($line = fgets($content)) !== false) {
86 -
            $explode_line = explode(" ", trim($line));
86 +
            $explode_line = explode(' ', trim($line));
87 87
            $tag = $explode_line[0];
88 88
            $meaning = $explode_line[1];
89 89
            self::$pos_tag_readable[$tag] = $meaning;
@@ -186,7 +186,7 @@
Loading
186 186
187 187
            foreach ($prev_mem_path as $mem_path_state) {
188 188
                if (count(self::$prob_trans[$mem_path_state])>0) {
189 -
                    array_push($prev_states, $mem_path_state);
189 +
                    $prev_states[] = $mem_path_state;
190 190
                }
191 191
            }
192 192
@@ -258,7 +258,7 @@
Loading
258 258
259 259
        $route = array();
260 260
        for ($t=0; $t<$obs_length; $t++) {
261 -
            array_push($route, 'None');
261 +
            $route[] = 'None';
262 262
        }
263 263
264 264
        $i = $obs_length-1;
@@ -269,7 +269,7 @@
Loading
269 269
            $i-=1;
270 270
        }
271 271
272 -
        return array("prob"=>$return_prob, "pos_list"=>$route);
272 +
        return array('prob'=>$return_prob, 'pos_list'=>$route);
273 273
    }// end function viterbi
274 274
275 275
    /**
@@ -280,7 +280,7 @@
Loading
280 280
     *
281 281
     * @return array $words
282 282
     */
283 -
    public static function __cut($sentence, $options = array("HMM" => true))
283 +
    public static function __cut($sentence, $options = array('HMM' => true))
284 284
    {
285 285
        $defaults = array(
286 286
            'mode'=>'default'
@@ -310,19 +310,19 @@
Loading
310 310
                eval('$this_pos_array = array'.$pos_list[$i].';');
311 311
                $this_pos = $this_pos_array[1];
312 312
                $this_word_pair = array(
313 -
                    "word"=>mb_substr($sentence, $begin, (($i+1)-$begin), 'UTF-8'),
314 -
                    "tag"=>$this_pos
313 +
                    'word'=>mb_substr($sentence, $begin, (($i+1)-$begin), 'UTF-8'),
314 +
                    'tag'=>$this_pos
315 315
                );
316 -
                array_push($words, $this_word_pair);
316 +
                $words[] = $this_word_pair;
317 317
                $next = $i+1;
318 318
            } elseif ($pos=='S') {
319 319
                eval('$this_pos_array = array'.$pos_list[$i].';');
320 320
                $this_pos = $this_pos_array[1];
321 321
                $this_word_pair = array(
322 -
                    "word"=>$char,
323 -
                    "tag"=>$this_pos
322 +
                    'word'=>$char,
323 +
                    'tag'=>$this_pos
324 324
                );
325 -
                array_push($words, $this_word_pair);
325 +
                $words[] = $this_word_pair;
326 326
                $next = $i+1;
327 327
            }
328 328
        }
@@ -331,10 +331,10 @@
Loading
331 331
            eval('$this_pos_array = array'.$pos_list[$next].';');
332 332
            $this_pos = $this_pos_array[1];
333 333
            $this_word_pair = array(
334 -
                "word"=>mb_substr($sentence, $next, null, 'UTF-8'),
335 -
                "tag"=>$this_pos
334 +
                'word'=>mb_substr($sentence, $next, null, 'UTF-8'),
335 +
                'tag'=>$this_pos
336 336
            );
337 -
            array_push($words, $this_word_pair);
337 +
            $words[] = $this_word_pair;
338 338
        }
339 339
340 340
        return $words;
@@ -378,16 +378,16 @@
Loading
378 378
            if (preg_match('/'.$re_han_pattern.'/u', $blk)) {
379 379
                $blk_words = self::__cut($blk);
380 380
                foreach ($blk_words as $blk_word) {
381 -
                    array_push($words, $blk_word);
381 +
                    $words[] = $blk_word;
382 382
                }
383 383
            } elseif (preg_match('/'.$re_skip_pattern.'/u', $blk)) {
384 384
                if (preg_match('/'.$re_num_pattern.'/u', $blk)) {
385 -
                    array_push($words, array("word"=>$blk, "tag"=>"m"));
385 +
                    $words[] = array('word' => $blk, 'tag' => 'm');
386 386
                } elseif (preg_match('/'.$re_eng_pattern.'/u', $blk)) {
387 -
                    array_push($words, array("word"=>$blk, "tag"=>"eng"));
387 +
                    $words[] = array('word' => $blk, 'tag' => 'eng');
388 388
                }
389 389
            } elseif (preg_match('/'.$re_punctuation_pattern.'/u', $blk)) {
390 -
                array_push($words, array("word"=>$blk, "tag"=>"w"));
390 +
                $words[] = array('word' => $blk, 'tag' => 'w');
391 391
            }
392 392
        }
393 393
@@ -433,18 +433,15 @@
Loading
433 433
                        if (isset(self::$word_tag[$buf])) {
434 434
                            $buf_tag = self::$word_tag[$buf];
435 435
                        } else {
436 -
                            $buf_tag = "x";
436 +
                            $buf_tag = 'x';
437 437
                        }
438 -
                        array_push(
439 -
                            $words,
440 -
                            array("word"=>$buf, "tag"=>$buf_tag)
441 -
                        );
438 +
                        $words[] = array('word' => $buf, 'tag' => $buf_tag);
442 439
                        $buf = '';
443 440
                    } else {
444 441
                        if (! isset(Jieba::$FREQ[$buf])) {
445 442
                            $regognized = self::__cutDetail($buf);
446 443
                            foreach ($regognized as $key => $word) {
447 -
                                array_push($words, $word);
444 +
                                $words[] = $word;
448 445
                            }
449 446
                        } else {
450 447
                            $elem_array = preg_split('//u', $buf, -1, PREG_SPLIT_NO_EMPTY);
@@ -452,12 +449,9 @@
Loading
452 449
                                if (isset(self::$word_tag[$word])) {
453 450
                                    $buf_tag = self::$word_tag[$word];
454 451
                                } else {
455 -
                                    $buf_tag = "x";
452 +
                                    $buf_tag = 'x';
456 453
                                }
457 -
                                array_push(
458 -
                                    $words,
459 -
                                    array("word"=>$word, "tag"=>$buf_tag)
460 -
                                );
454 +
                                $words[] = array('word' => $word, 'tag' => $buf_tag);
461 455
                            }
462 456
                        }
463 457
                        $buf = '';
@@ -467,12 +461,9 @@
Loading
467 461
                if (isset(self::$word_tag[$l_word])) {
468 462
                    $buf_tag = self::$word_tag[$l_word];
469 463
                } else {
470 -
                    $buf_tag = "x";
464 +
                    $buf_tag = 'x';
471 465
                }
472 -
                array_push(
473 -
                    $words,
474 -
                    array("word"=>$l_word, "tag"=>$buf_tag)
475 -
                );
466 +
                $words[] = array('word' => $l_word, 'tag' => $buf_tag);
476 467
            }
477 468
            $x = $y;
478 469
        }
@@ -482,17 +473,14 @@
Loading
482 473
                if (isset(self::$word_tag[$buf])) {
483 474
                    $buf_tag = self::$word_tag[$buf];
484 475
                } else {
485 -
                    $buf_tag = "x";
476 +
                    $buf_tag = 'x';
486 477
                }
487 -
                array_push(
488 -
                    $words,
489 -
                    array("word"=>$buf, "tag"=>$buf_tag)
490 -
                );
478 +
                $words[] = array('word'=>$buf, 'tag'=>$buf_tag);
491 479
            } else {
492 480
                if (! isset(Jieba::$FREQ[$buf])) {
493 481
                    $regognized = self::__cutDetail($buf);
494 482
                    foreach ($regognized as $key => $word) {
495 -
                        array_push($words, $word);
483 +
                        $words[] = $word;
496 484
                    }
497 485
                } else {
498 486
                    $elem_array = preg_split('//u', $buf, -1, PREG_SPLIT_NO_EMPTY);
@@ -500,12 +488,9 @@
Loading
500 488
                        if (isset(self::$word_tag[$word])) {
501 489
                            $buf_tag = self::$word_tag[$word];
502 490
                        } else {
503 -
                            $buf_tag = "x";
491 +
                            $buf_tag = 'x';
504 492
                        }
505 -
                        array_push(
506 -
                            $words,
507 -
                            array("word"=>$word, "tag"=>$buf_tag)
508 -
                        );
493 +
                        $words[] = array('word'=>$word, 'tag'=>$buf_tag);
509 494
                    }
510 495
                }
511 496
            }
@@ -555,23 +540,17 @@
Loading
555 540
                    if (isset(self::$word_tag[$buf])) {
556 541
                        $buf_tag = self::$word_tag[$buf];
557 542
                    } else {
558 -
                        $buf_tag = "x";
543 +
                        $buf_tag = 'x';
559 544
                    }
560 -
                    array_push(
561 -
                        $words,
562 -
                        array("word"=>$buf, "tag"=>$buf_tag)
563 -
                    );
545 +
                    $words[] = array('word' => $buf, 'tag' => $buf_tag);
564 546
                    $buf = '';
565 547
                }
566 548
                if (isset(self::$word_tag[$l_word])) {
567 549
                    $buf_tag = self::$word_tag[$l_word];
568 550
                } else {
569 -
                    $buf_tag = "x";
551 +
                    $buf_tag = 'x';
570 552
                }
571 -
                array_push(
572 -
                    $words,
573 -
                    array("word"=>$l_word, "tag"=>$buf_tag)
574 -
                );
553 +
                $words[] = array('word' => $l_word, 'tag' => $buf_tag);
575 554
                $x = $y;
576 555
            }
577 556
        }
@@ -580,12 +559,9 @@
Loading
580 559
            if (isset(self::$word_tag[$buf])) {
581 560
                $buf_tag = self::$word_tag[$buf];
582 561
            } else {
583 -
                $buf_tag = "x";
562 +
                $buf_tag = 'x';
584 563
            }
585 -
            array_push(
586 -
                $words,
587 -
                array("word"=>$buf, "tag"=>$buf_tag)
588 -
            );
564 +
            $words[] = array('word' => $buf, 'tag' => $buf_tag);
589 565
        }
590 566
591 567
        return $words;
@@ -599,7 +575,7 @@
Loading
599 575
     *
600 576
     * @return array $seg_list
601 577
     */
602 -
    public static function cut($sentence, $options = array("HMM" => true))
578 +
    public static function cut($sentence, $options = array('HMM' => true))
603 579
    {
604 580
        $defaults = array(
605 581
            'mode'=>'default'
@@ -634,16 +610,16 @@
Loading
634 610
                }
635 611
636 612
                foreach ($words as $word) {
637 -
                    array_push($seg_list, $word);
613 +
                    $seg_list[] = $word;
638 614
                }
639 615
            } elseif (preg_match('/'.$re_skip_pattern.'/u', $blk)) {
640 616
                if (preg_match('/'.$re_num_pattern.'/u', $blk)) {
641 -
                    array_push($seg_list, array("word"=>$blk, "tag"=>"m"));
617 +
                    $seg_list[] = array('word' => $blk, 'tag' => 'm');
642 618
                } elseif (preg_match('/'.$re_eng_pattern.'/u', $blk)) {
643 -
                    array_push($seg_list, array("word"=>$blk, "tag"=>"eng"));
619 +
                    $seg_list[] = array('word' => $blk, 'tag' => 'eng');
644 620
                }
645 621
            } elseif (preg_match('/'.$re_punctuation_pattern.'/u', $blk)) {
646 -
                array_push($seg_list, array("word"=>$blk, "tag"=>"w"));
622 +
                $seg_list[] = array('word' => $blk, 'tag' => 'w');
647 623
            }
648 624
        }
649 625
@@ -670,7 +646,7 @@
Loading
670 646
671 647
        foreach ($seg_list as $seg) {
672 648
            $seg['tag_readable'] = self::$pos_tag_readable[$seg['tag']];
673 -
            array_push($new_seg_list, $seg);
649 +
            $new_seg_list[] = $seg;
674 650
        }
675 651
676 652
        return $new_seg_list;

@@ -93,7 +93,7 @@
Loading
93 93
        while (($line = fgets($content)) !== false) {
94 94
            $stop_word = strtolower(trim($line));
95 95
            if (! in_array($stop_word, self::$stop_words)) {
96 -
                array_push(self::$stop_words, $stop_word);
96 +
                self::$stop_words[] = $stop_word;
97 97
            }
98 98
        }
99 99
        fclose($content);

@@ -139,9 +139,9 @@
Loading
139 139
                if (is_array($path[$max_key])) {
140 140
                    $newpath[$y] = array();
141 141
                    foreach ($path[$max_key] as $key => $path_value) {
142 -
                        array_push($newpath[$y], $path_value);
142 +
                        $newpath[$y][] = $path_value;
143 143
                    }
144 -
                    array_push($newpath[$y], $y);
144 +
                    $newpath[$y][] = $y;
145 145
                } else {
146 146
                    $newpath[$y] = array($path[$max_key], $y);
147 147
                }
@@ -197,16 +197,16 @@
Loading
197 197
            if ($pos=='B') {
198 198
                $begin = $i;
199 199
            } elseif ($pos=='E') {
200 -
                array_push($words, mb_substr($sentence, $begin, (($i+1)-$begin), 'UTF-8'));
200 +
                $words[] = mb_substr($sentence, $begin, (($i+1)-$begin), 'UTF-8');
201 201
                $next = $i+1;
202 202
            } elseif ($pos=='S') {
203 -
                array_push($words, $char);
203 +
                $words[] = $char;
204 204
                $next = $i+1;
205 205
            }
206 206
        }
207 207
208 208
        if ($next<$len) {
209 -
            array_push($words, mb_substr($sentence, $next, null, 'UTF-8'));
209 +
            $words[] = mb_substr($sentence, $next, null, 'UTF-8');
210 210
        }
211 211
212 212
        return $words;
@@ -250,12 +250,12 @@
Loading
250 250
                $words = self::__cut($blk);
251 251
252 252
                foreach ($words as $word) {
253 -
                    array_push($seg_list, $word);
253 +
                    $seg_list[] = $word;
254 254
                }
255 255
256 256
            } else {
257 257
258 -
                array_push($seg_list, $blk);
258 +
                $seg_list[] = $blk;
259 259
260 260
            }// end else (preg_match('/'.$re_han_pattern.'/u', $blk))
261 261

@@ -173,7 +173,7 @@
Loading
173 173
                //$word_c = array();
174 174
                //for ($i=0; $i<$l; $i++) {
175 175
                //    $c = mb_substr($word, $i, 1, 'UTF-8');
176 -
                //    array_push($word_c, $c);
176 +
                //    $word_c[] = $c;
177 177
                //}
178 178
                //$word_c_key = implode('.', $word_c);
179 179
                //self::$trie->set($word_c_key, array("end"=>""));
@@ -219,7 +219,7 @@
Loading
219 219
     */
220 220
    public static function loadUserDict($f_name, $options = array())
221 221
    {
222 -
        array_push(self::$user_dictname, $f_name);
222 +
        self::$user_dictname[] = $f_name;
223 223
        $content = fopen($f_name, "r");
224 224
        while (($line = fgets($content)) !== false) {
225 225
            $explode_line = explode(" ", trim($line));
@@ -233,7 +233,7 @@
Loading
233 233
            $word_c = array();
234 234
            for ($i=0; $i<$l; $i++) {
235 235
                $c = mb_substr($word, $i, 1, 'UTF-8');
236 -
                array_push($word_c, $c);
236 +
                $word_c[] = $c;
237 237
            }
238 238
            $word_c_key = implode('.', $word_c);
239 239
            self::$trie->set($word_c_key, array("end"=>""));
@@ -267,13 +267,13 @@
Loading
267 267
        foreach ($DAG as $k => $L) {
268 268
            if (count($L) == 1 && $k > $old_j) {
269 269
                $word = mb_substr($sentence, $k, (($L[0]-$k)+1), 'UTF-8');
270 -
                array_push($words, $word);
270 +
                $words[] = $word;
271 271
                $old_j = $L[0];
272 272
            } else {
273 273
                foreach ($L as $j) {
274 274
                    if ($j > $k) {
275 275
                        $word = mb_substr($sentence, $k, ($j-$k)+1, 'UTF-8');
276 -
                        array_push($words, $word);
276 +
                        $words[] = $word;
277 277
                        $old_j = $j;
278 278
                    }
279 279
                }
@@ -314,7 +314,7 @@
Loading
314 314
            }
315 315
316 316
            if (self::$trie->exists($next_word_key)) {
317 -
                array_push($word_c, $c);
317 +
                $word_c[] = $c;
318 318
                $next_word_key_value = self::$trie->get($next_word_key);
319 319
                if ($next_word_key_value == array("end"=>"")
320 320
                 || isset($next_word_key_value["end"])
@@ -323,7 +323,7 @@
Loading
323 323
                    if (!isset($DAG[$i])) {
324 324
                        $DAG[$i] = array();
325 325
                    }
326 -
                    array_push($DAG[$i], $j);
326 +
                    $DAG[$i][] = $j;
327 327
                }
328 328
                $j += 1;
329 329
                if ($j >= $N) {
@@ -383,28 +383,28 @@
Loading
383 383
            } else {
384 384
                if (mb_strlen($buf, 'UTF-8')>0) {
385 385
                    if (mb_strlen($buf, 'UTF-8')==1) {
386 -
                        array_push($words, $buf);
386 +
                        $words[] = $buf;
387 387
                        $buf = '';
388 388
                    } else {
389 389
                        $regognized = Finalseg::cut($buf);
390 390
                        foreach ($regognized as $key => $word) {
391 -
                            array_push($words, $word);
391 +
                            $words[] = $word;
392 392
                        }
393 393
                        $buf = '';
394 394
                    }
395 395
                }
396 -
                array_push($words, $l_word);
396 +
                $words[] = $l_word;
397 397
            }
398 398
            $x = $y;
399 399
        }
400 400
401 401
        if (mb_strlen($buf, 'UTF-8')>0) {
402 402
            if (mb_strlen($buf, 'UTF-8')==1) {
403 -
                array_push($words, $buf);
403 +
                $words[] = $buf;
404 404
            } else {
405 405
                $regognized = Finalseg::cut($buf);
406 406
                foreach ($regognized as $key => $word) {
407 -
                    array_push($words, $word);
407 +
                    $words[] = $word;
408 408
                }
409 409
            }
410 410
        }
@@ -450,10 +450,10 @@
Loading
450 450
                }
451 451
452 452
                foreach ($words as $word) {
453 -
                    array_push($seg_list, $word);
453 +
                    $seg_list[] = $word;
454 454
                }
455 455
            } else {
456 -
                array_push($seg_list, $blk);
456 +
                $seg_list[] = $blk;
457 457
            }// end else (preg_match('/'.$re_han_pattern.'/u', $blk))
458 458
        }// end foreach ($blocks as $blk)
459 459
@@ -488,7 +488,7 @@
Loading
488 488
                    $gram2 = mb_substr($w, $i, 2, 'UTF-8');
489 489
490 490
                    if (isset(self::$FREQ[$gram2])) {
491 -
                        array_push($seg_list, $gram2);
491 +
                        $seg_list[] = $gram2;
492 492
                    }
493 493
                }
494 494
            }
@@ -498,12 +498,12 @@
Loading
498 498
                    $gram3 = mb_substr($w, $i, 3, 'UTF-8');
499 499
500 500
                    if (isset(self::$FREQ[$gram3])) {
501 -
                        array_push($seg_list, $gram3);
501 +
                        $seg_list[] = $gram3;
502 502
                    }
503 503
                }
504 504
            }
505 505
506 -
            array_push($seg_list, $w);
506 +
            $seg_list[] = $w;
507 507
        }
508 508
509 509
        return $seg_list;
Files Complexity Coverage
src/class 268 55.48%
Project Totals (5 files) 268 55.48%
140.1
TRAVIS_PHP_VERSION=7.1
TRAVIS_OS_NAME=linux
140.2
TRAVIS_PHP_VERSION=7.2
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading