Example #1
0
 public function pluralize($word, $count)
 {
     if ($count == 1) {
         return $word;
     }
     $word = lower($word);
     if (in_array($word, self::$without_paired_form)) {
         return $word;
     } else {
         if (isset(self::$exceptions[$word])) {
             return self::$exceptions[$word];
         }
     }
     if (in_array(slice($word, -1), array('s', 'x')) || in_array(slice($word, -2), array('sh', 'ch'))) {
         return $word . 'es';
     } else {
         if (slice($word, -1) == 'o') {
             return $word . 'es';
         } else {
             if (slice($word, -1) == 'y' && in_array(slice($word, -2, -1), self::$consonants)) {
                 return slice($word, 0, -1) . 'ies';
             } else {
                 if (slice($word, -2) == 'fe' || slice($word, -1) == 'f') {
                     if (slice($word, -1) == 'f') {
                         return slice($word, 0, -1) . 'ves';
                     } else {
                         return slice($word, 0, -2) . 'ves';
                     }
                 } else {
                     return $word . 's';
                 }
             }
         }
     }
 }
Example #2
0
/**
 * Name case. (ex: Thomas Lewis)
 */
function name($string)
{
    if (function_exists('mb_strtoupper')) {
        return upper(slice($string, 0, 1)) . lower(slice($string, 1));
    } else {
        return false;
    }
}
Example #3
0
 public function checkLastConsonantSoftness($word)
 {
     if (($substring = last_position_for_one_of_chars(lower($word), array_map(__NAMESPACE__ . '\\lower', self::$consonants))) !== false) {
         if (in_array(slice($substring, 0, 1), ['й', 'ч', 'щ'])) {
             // always soft consonants
             return true;
         } else {
             if (length($substring) > 1 && in_array(slice($substring, 1, 2), ['е', 'ё', 'и', 'ю', 'я', 'ь'])) {
                 // consonants are soft if they are trailed with these vowels
                 return true;
             }
         }
     }
     return false;
 }
Example #4
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Start offset must be non-negative
  */
 public function testSliceNegativeStartOffsetError()
 {
     toArray(slice(range(0, INF), -1, 5));
 }
     $dwn = cut_str($snap, 'href="', '"');
     $Url = parse_url($dwn);
     $FileName = basename($Url["path"]);
     insert_location("index.php?filename=" . urlencode($FileName) . "&force_name=" . urlencode($FileName) . "&host=" . $Url["host"] . "&port=" . $Url["port"] . "&path=" . urlencode($Url["path"] . ($Url["query"] ? "?" . $Url["query"] : "")) . "&referer=" . urlencode($Referer) . "&cookie=" . urlencode($cookie) . "&email=" . ($_GET["domail"] ? $_GET["email"] : "") . "&partSize=" . ($_GET["split"] ? $_GET["partSize"] : "") . "&method=" . $_GET["method"] . "&proxy=" . ($_GET["useproxy"] ? $_GET["proxy"] : "") . "&saveto=" . $_GET["path"] . "&link=" . urlencode($LINK) . ($_GET["add_comment"] == "on" ? "&comment=" . urlencode($_GET["comment"]) : "") . ($pauth ? "&pauth={$pauth}" : "") . (isset($_GET["audl"]) ? "&audl=doum" : ""));
 } else {
     $page = geturl($Url["host"], $Url["port"] ? $Url["port"] : 80, $Url["path"] . ($Url["query"] ? "?" . $Url["query"] : ""), 0, 0, 0, 0, $_GET["proxy"], $pauth);
     is_page($page);
     $page = geturl($Url["host"], $Url["port"] ? $Url["port"] : 80, $Url["path"] . ($Url["query"] ? "?" . $Url["query"] : ""), $LINK, 0, 0, 0, $_GET["proxy"], $pauth);
     is_page($page);
     is_present($page, "The requested file was not found");
     is_present($page, "Gesuchte Datei wurde nicht gefunden", "The requested file was not found");
     is_present($page, "Запрашиваемый файл не найден", "The requested file was not found");
     $cookie = biscottiDiKaox($page);
     $FreeForm = cut_str($page, 'id="dvifree">', '</form>');
     $act = "http://" . cut_str($page, 'form action="http://', '"');
     $uid = slice($FreeForm, 'name="uid" value="', '"', 2);
     $md5crypt = cut_str($FreeForm, '="md5crypt" value="', '"');
     // $uid2 = cut_str($FreeForm,'name="uid2" value="','"');
     $uid5 = cut_str($FreeForm, 'name="uid5" value="', '"');
     $name = cut_str($FreeForm, 'name="name" value="', '"');
     $pin = cut_str($FreeForm, ' name="pin" value="', '"');
     $realuid = cut_str($FreeForm, 'e="realuid" value="', '"');
     $realname = cut_str($FreeForm, '="realname" value="', '"');
     $host = cut_str($FreeForm, 'name="host" value="', '"');
     $ssserver = cut_str($FreeForm, '="ssserver" value="', '"');
     $sssize = cut_str($FreeForm, 'me="sssize" value="', '"');
     $post['uid'] = $uid;
     $post['md5crypt'] = $md5crypt;
     $post['frameset'] = 'Download file';
     //  $post['uid2']=$uid2;
     $post['uid5'] = $uid5;
function output($data, $isFilter = false)
{
    // header("Content-Range: /" . count($GLOBALS['data']));
    // header("Content-Range:" . 'items 0-' . count($data) . '/' . count($GLOBALS['data']));
    if ($isFilter) {
        header("Content-Range: " . $GLOBALS['totalCount'] . "/" . count($data));
    } else {
        header("Content-Range: /" . count($data));
    }
    $data = slice($data);
    echo json_encode($data);
}
 public function getForms($name, $gender)
 {
     $name = lower($name);
     if ($gender == self::MAN) {
         if (in_array(upper(slice($name, -1)), array_diff(self::$consonants, array('Й')))) {
             // hard consonant
             $prefix = name($name);
             // special cases for Лев, Павел
             if ($name == 'лев') {
                 return $this->getFormsForLev();
             } else {
                 if ($name == 'павел') {
                     return $this->getFormsForPavel();
                 } else {
                     return array(self::IMENIT_1 => $prefix, self::RODIT_2 => $prefix . 'а', self::DAT_3 => $prefix . 'у', self::VINIT_4 => $prefix . 'а', self::TVORIT_5 => $this->isHissingConsonant(slice($name, -1)) || slice($name, -1) == 'ц' ? $prefix . 'ем' : $prefix . 'ом', self::PREDLOJ_6 => in_array(upper(slice($name, 0, 1)), self::$vowels) ? 'об ' . $prefix . 'е' : 'о ' . $prefix . 'е');
                 }
             }
         } else {
             if (slice($name, -1) == 'ь' && in_array(upper(slice($name, -2, -1)), self::$consonants)) {
                 // soft consonant
                 $prefix = name(slice($name, 0, -1));
                 return array(self::IMENIT_1 => $prefix . 'ь', self::RODIT_2 => $prefix . 'я', self::DAT_3 => $prefix . 'ю', self::VINIT_4 => $prefix . 'я', self::TVORIT_5 => $prefix . 'ем', self::PREDLOJ_6 => in_array(upper(slice($name, 0, 1)), self::$vowels) ? 'об ' . $prefix . 'е' : 'о ' . $prefix . 'е');
             } else {
                 if (in_array(slice($name, -2), array('ай', 'ей', 'ой', 'уй', 'яй', 'юй', 'ий'))) {
                     $prefix = name(slice($name, 0, -1));
                     $postfix = slice($name, -2) == 'ий' ? 'и' : 'е';
                     return array(self::IMENIT_1 => $prefix . 'й', self::RODIT_2 => $prefix . 'я', self::DAT_3 => $prefix . 'ю', self::VINIT_4 => $prefix . 'я', self::TVORIT_5 => $prefix . 'ем', self::PREDLOJ_6 => in_array(upper(slice($name, 0, 1)), self::$vowels) ? 'об ' . $prefix . $postfix : 'о ' . $prefix . $postfix);
                 } else {
                     if (slice($name, -1) == 'а' && ($before = slice($name, -2, -1)) && $this->isConsonant($before) && !in_array($before, array('ц'))) {
                         $prefix = name(slice($name, 0, -1));
                         $postfix = $this->isHissingConsonant($before) || in_array($before, array('г', 'к', 'х')) ? 'и' : 'ы';
                         return array(self::IMENIT_1 => $prefix . 'а', self::RODIT_2 => $prefix . $postfix, self::DAT_3 => $prefix . 'е', self::VINIT_4 => $prefix . 'у', self::TVORIT_5 => $prefix . 'ой', self::PREDLOJ_6 => in_array(upper(slice($name, 0, 1)), self::$vowels) ? 'об ' . $prefix . 'е' : 'о ' . $prefix . 'е');
                     } else {
                         if (slice($name, -2) == 'ия') {
                             $prefix = name(slice($name, 0, -1));
                             return array(self::IMENIT_1 => $prefix . 'я', self::RODIT_2 => $prefix . 'и', self::DAT_3 => $prefix . 'и', self::VINIT_4 => $prefix . 'ю', self::TVORIT_5 => $prefix . 'ей', self::PREDLOJ_6 => in_array(upper(slice($name, 0, 1)), self::$vowels) ? 'об ' . $prefix . 'и' : 'о ' . $prefix . 'и');
                         } else {
                             if (slice($name, -2) == 'ло' || slice($name, -2) == 'ко') {
                                 $prefix = name(slice($name, 0, -1));
                                 $postfix = slice($name, -2, -1) == 'к' ? 'и' : 'ы';
                                 return array(self::IMENIT_1 => $prefix . 'о', self::RODIT_2 => $prefix . $postfix, self::DAT_3 => $prefix . 'е', self::VINIT_4 => $prefix . 'у', self::TVORIT_5 => $prefix . 'ой', self::PREDLOJ_6 => in_array(upper(slice($name, 0, 1)), self::$vowels) ? 'об ' . $prefix . 'е' : 'о ' . $prefix . 'е');
                             } else {
                                 return false;
                             }
                         }
                     }
                 }
             }
         }
     } else {
         if (slice($name, -1) == 'а' && ($before = slice($name, -2, -1))) {
             $prefix = name(slice($name, 0, -1));
             if ($before != 'ц') {
                 $postfix = $this->isHissingConsonant($before) || in_array($before, array('г', 'к', 'х')) ? 'и' : 'ы';
                 return array(self::IMENIT_1 => $prefix . 'а', self::RODIT_2 => $prefix . $postfix, self::DAT_3 => $prefix . 'е', self::VINIT_4 => $prefix . 'у', self::TVORIT_5 => $prefix . 'ой', self::PREDLOJ_6 => in_array(upper(slice($name, 0, 1)), self::$vowels) ? 'об ' . $prefix . 'е' : 'о ' . $prefix . 'е');
             } else {
                 return array(self::IMENIT_1 => $prefix . 'а', self::RODIT_2 => $prefix . 'ы', self::DAT_3 => $prefix . 'е', self::VINIT_4 => $prefix . 'у', self::TVORIT_5 => $prefix . 'ей', self::PREDLOJ_6 => in_array(upper(slice($name, 0, 1)), self::$vowels) ? 'об ' . $prefix . 'е' : 'о ' . $prefix . 'е');
             }
         } else {
             if (slice($name, -1) == 'я' and slice($name, -2, -1) != 'и') {
                 $prefix = name(slice($name, 0, -1));
                 return array(self::IMENIT_1 => $prefix . 'я', self::RODIT_2 => $prefix . 'и', self::DAT_3 => $prefix . 'е', self::VINIT_4 => $prefix . 'ю', self::TVORIT_5 => $prefix . 'ей', self::PREDLOJ_6 => in_array(upper(slice($name, 0, 1)), self::$vowels) ? 'об ' . $prefix . 'е' : 'о ' . $prefix . 'е');
             } else {
                 if (slice($name, -2) == 'ия') {
                     $prefix = name(slice($name, 0, -1));
                     return array(self::IMENIT_1 => $prefix . 'я', self::RODIT_2 => $prefix . 'и', self::DAT_3 => $prefix . 'и', self::VINIT_4 => $prefix . 'ю', self::TVORIT_5 => $prefix . 'ей', self::PREDLOJ_6 => in_array(upper(slice($name, 0, 1)), self::$vowels) ? 'об ' . $prefix . 'и' : 'о ' . $prefix . 'и');
                 } else {
                     if (slice($name, -1) == 'ь' && $this->isConsonant(slice($name, -2, -1))) {
                         $prefix = name(slice($name, 0, -1));
                         return array(self::IMENIT_1 => $prefix . 'ь', self::RODIT_2 => $prefix . 'и', self::DAT_3 => $prefix . 'и', self::VINIT_4 => $prefix . 'ь', self::TVORIT_5 => $prefix . 'ью', self::PREDLOJ_6 => in_array(upper(slice($name, 0, 1)), self::$vowels) ? 'об ' . $prefix . 'и' : 'о ' . $prefix . 'и');
                     } else {
                         if ($this->isHissingConsonant(slice($name, -1))) {
                             $prefix = name($name);
                             return array(self::IMENIT_1 => $prefix, self::RODIT_2 => $prefix . 'и', self::DAT_3 => $prefix . 'и', self::VINIT_4 => $prefix, self::TVORIT_5 => $prefix . 'ью', self::PREDLOJ_6 => in_array(upper(slice($name, 0, 1)), self::$vowels) ? 'об ' . $prefix . 'и' : 'о ' . $prefix . 'и');
                         } else {
                             return false;
                         }
                     }
                 }
             }
         }
     }
 }
Example #8
0
 public function testSlice()
 {
     $this->assertSame([5, 6, 7, 8, 9], toArray(slice(range(0, INF), 5, 5)));
     $this->assertSame([5, 6, 7, 8, 9], toArray(slice(range(0, 9), 5)));
 }
Example #9
0
 public function getItems($start, $size)
 {
     return slice($this->items, $start - 1, $size);
 }
Example #10
0
/**
 * Drops the first n items from an iterable.
 *
 * Examples:
 *
 *      iter\drop(3, [1, 2, 3, 4, 5])
 *      => iter(4, 5)
 *
 * @param int   $num      Number of elements to drop from the start
 * @param mixed $iterable Iterable to drop the elements from
 *
 * @return \Iterator
 */
function drop($num, $iterable)
{
    return slice($iterable, $num);
}
Example #11
0
 /**
  * Join conjunctions to surrounding pieces.
  *
  * - Mr. and Mrs.
  * - King of the Hill
  * - Jack & Jill
  * - Velasquez y Garcia
  *
  * Returns new array of pieces with the conjunctions merged into one piece
  * with spaces between.
  *
  * $additional_parts_count is used for when the comma format contains other parts,
  * so we know how many there are to decide if things should be considered a
  * conjunction.
  *
  * @access private
  * @param array $pieces
  * @param int $additional_parts_count
  * @return array
  */
 private function join_on_conjunctions($pieces, $additional_parts_count = 0)
 {
     if (count($pieces) + $additional_parts_count < 3) {
         return $pieces;
     }
     foreach (array_values(array_filter(array_reverse($pieces), array($this, 'is_conjunction'))) as $conj) {
         $rootname_pieces = array_values(array_filter($pieces, array($this, 'is_rootname')));
         $length = count($rootname_pieces) + $additional_parts_count;
         if (strlen($conj) == 1 && $length < 4) {
             continue;
         }
         if (!($i = array_search($conj, $pieces))) {
             continue;
         }
         if ($i < count($pieces) - 1) {
             if ($i == 0) {
                 $nxt = $pieces[$i + 1];
                 $new_piece = implode(' ', slice($pieces, 0, 2));
                 if ($this->is_title($nxt)) {
                     $this->C['titles'][] = lc($new_piece);
                 } else {
                     $this->C['conjunctions'][] = lc($new_piece);
                 }
                 $pieces[$i] = $new_piece;
                 $pieces = pop($pieces, $i + 1);
                 continue;
             }
             if ($this->is_conjunction($pieces[$i - 1])) {
                 $new_piece = implode(' ', slice($pieces, $i, $i + 2));
                 $this->C['conjunctions'][] = lc($new_piece);
                 $pieces[$i] = $new_piece;
                 $pieces = pop($pieces, $i + 1);
                 continue;
             }
             $new_piece = implode(' ', slice($pieces, $i - 1, $i + 2));
             if ($this->is_title($pieces[$i - 1])) {
                 $this->C['titles'][] = lc($new_piece);
             }
             $pieces[$i - 1] = $new_piece;
             $pieces = pop($pieces, $i);
             $pieces = pop($pieces, $i);
         }
     }
     if ($prefixes = array_values(array_filter($pieces, array($this, 'is_prefix')))) {
         $i = array_search($prefixes[0], $pieces);
         if ($next_suffix = array_values(array_filter(slice($pieces, $i), array($this, 'is_suffix')))) {
             $j = array_search($next_suffix[0], $pieces);
             $new_piece = implode(' ', slice($pieces, $i, $j));
             $pieces = array_merge(slice($pieces, 0, $i), array($new_piece), slice($pieces, $j));
         } else {
             $new_piece = implode(' ', slice($pieces, $i));
             $pieces = array_merge(slice($pieces, 0, $i), array($new_piece));
         }
     }
     return $pieces;
 }
Example #12
0
function merge_sort($array, $comparison)
{
    if (count($array) < 2) {
        return $array;
    }
    $middle = ceil(count($array) / 2);
    return merge(merge_sort(slice($array, 0, $middle), $comparison), merge_sort(slice($array, $middle), $comparison), $comparison);
}
 protected function getPredCaseOf12Declensions($word, $last, $prefix)
 {
     if (slice($word, -2) == 'ий') {
         if ($last == 'ё') {
             return $prefix . 'е';
         } else {
             return $prefix . 'и';
         }
     } else {
         return $prefix . 'е';
     }
 }