コード例 #1
0
ファイル: word_processor.php プロジェクト: bnordb/ICS325
 function getWordWeight()
 {
     $len = $this->getLength();
     // non-Telugu
     if (!isTelugu($this->getCodePoints()[0][0])) {
         return $len;
     }
     $weight = 0;
     foreach ($this->getCodePoints() as $char) {
         $weight += count($char);
     }
     return $weight;
 }
コード例 #2
0
ファイル: telugu_parser.php プロジェクト: bnordb/ICS325
function explode_telugu($to_explode)
{
    $pos = 0;
    $e_pos = 0;
    $exploded = array();
    while ($pos < strlen($to_explode) - 1) {
        if (strcmp($to_explode[$pos], "\"") == 0) {
            $pos++;
            continue;
        }
        if (strcmp($to_explode[$pos], "\\") == 0) {
            // if the the character in question is a slash...
            if (strcmp($to_explode[$pos + 1], "u") == 0) {
                // ...followed by a u...
                $char = 0 + ("0x" . substr($to_explode, $pos + 2, 4));
                // convert to a number
                if (isTelugu($char)) {
                    // if it matches, add it as a character, bump the counter up by six, and continue
                    $exploded[$e_pos++] = $char;
                    $pos += 6;
                    continue;
                }
            }
        }
        $exploded[$e_pos++] = ord($to_explode[$pos++]);
    }
    return $exploded;
}