public static function calc($sentence, $DAG, $options = array())
    {
        $N = mb_strlen($sentence, 'UTF-8');
        self::$route = array();
        self::$route[$N] = array($N => 1.0);
        for ($i=($N-1); $i>=0; $i--) {
            $candidates = array();
            foreach ($DAG[$i] as $x) {
                $w_c = mb_substr($sentence, $i, (($x+1)-$i), 'UTF-8');
                $previous_freq = current(self::$route[$x+1]);
                if (isset(self::$FREQ[$w_c])) {
                    $current_freq = (float) $previous_freq + self::$FREQ[$w_c];
                } else {
                    $current_freq = (float) $previous_freq + self::$min_freq;
                }
                $candidates[$x] = $current_freq;
            }
            arsort($candidates);
            $max_prob = reset($candidates);
            $max_key = key($candidates);
            self::$route[$i] = array($max_key => $max_prob);
        }

        return self::$route;
    }
public static function calc($sentence, $DAG, $options = array())
    {
        $N = mb_strlen($sentence, 'UTF-8');
        self::$route = array();
        self::$route[$N] = array($N => 1.0);
        for ($i=($N-1); $i>=0; $i--) {
            $candidates = array();
            foreach ($DAG[$i] as $x) {
                $w_c = mb_substr($sentence, $i, (($x+1)-$i), 'UTF-8');
                $previous_freq = current(self::$route[$x+1]);
                if (isset(self::$FREQ[$w_c])) {
                    $current_freq = (float) $previous_freq + self::$FREQ[$w_c];
                } else {
                    $current_freq = (float) $previous_freq + self::$min_freq;
                }
                $candidates[$x] = $current_freq;
            }
            arsort($candidates);
            $max_prob = reset($candidates);
            $max_key = key($candidates);
            self::$route[$i] = array($max_key => $max_prob);
        }

        return self::$route;
    }
public static function calc ( $ sentence , $ DAG , $ options = array ( ) ) { $ N = mb_strlen ( $ sentence , 'UTF-8' ) ; self :: $ route = array ( ) ; self :: $ route [ $ N ] = array ( $ N => 1.0 ) ; for ( $ i = ( $ N - 1 ) ; $ i >= 0 ; $ i -- ) { $ candidates = array ( ) ; foreach ( $ DAG [ $ i ] as $ x ) { $ w_c = mb_substr ( $ sentence , $ i , ( ( $ x + 1 ) - $ i ) , 'UTF-8' ) ; $ previous_freq = current ( self :: $ route [ $ x + 1 ] ) ; if ( isset ( self :: $ FREQ [ $ w_c ] ) ) { $ current_freq = ( float ) $ previous_freq + self :: $ FREQ [ $ w_c ] ; } else { $ current_freq = ( float ) $ previous_freq + self :: $ min_freq ; } $ candidates [ $ x ] = $ current_freq ; } arsort ( $ candidates ) ; $ max_prob = reset ( $ candidates ) ; $ max_key = key ( $ candidates ) ; self :: $ route [ $ i ] = array ( $ max_key => $ max_prob ) ; } return self :: $ route ; }
Static method calc

@param string $sentence # input sentence
@param array  $DAG      # DAG
@param array  $options  # other options

@return array self::$route
Static method calc