本文整理汇总了PHP中Transform::createOrLoad方法的典型用法代码示例。如果您正苦于以下问题:PHP Transform::createOrLoad方法的具体用法?PHP Transform::createOrLoad怎么用?PHP Transform::createOrLoad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform::createOrLoad方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extractTransforms
static function extractTransforms($from, $to, $isPronoun)
{
// Vowel count after the accent
$accentPosFrom = self::findAccentPosition($from);
$accentPosTo = self::findAccentPosition($to);
// String position of the accent
$accentIndexFrom = mb_strpos($from, "'");
$accentIndexTo = mb_strpos($to, "'");
if ($accentIndexTo !== false) {
$accentedVowelTo = StringUtil::getCharAt($to, $accentIndexTo + 1);
}
$from = str_replace("'", '', $from);
$to = str_replace("'", '', $to);
$t = self::extractTransformsNoAccents($from, $to, $isPronoun);
if ($t == null) {
return null;
}
if (!count($t)) {
$t[] = Transform::createOrLoad('', '');
}
if (!$accentPosFrom || !$accentPosTo) {
$accentShift = UNKNOWN_ACCENT_SHIFT;
} else {
if ($accentIndexFrom == $accentIndexTo && mb_substr($from, 0, $accentIndexFrom + 1) == mb_substr($to, 0, $accentIndexTo + 1)) {
// Compare the beginning of $from and $to, up to and including the
// accented character. Note that we have already removed the accent,
// so we only add 1 above, not 2.
$accentShift = NO_ACCENT_SHIFT;
} else {
$accentShift = $accentPosTo;
$t[] = $accentedVowelTo;
}
}
$t[] = $accentShift;
return $t;
}
示例2: foreach
foreach ($regenTransforms as $inflId => $transformMatrix) {
db_execute("delete from ModelDescription where modelId = {$model->id} and inflectionId = {$inflId}");
$variant = 0;
foreach ($transformMatrix as $transforms) {
$accentShift = array_pop($transforms);
if ($accentShift != UNKNOWN_ACCENT_SHIFT && $accentShift != NO_ACCENT_SHIFT) {
$accentedVowel = array_pop($transforms);
} else {
$accentedVowel = '';
}
$order = 0;
$mds = array();
for ($i = count($transforms) - 1; $i >= 0; $i--) {
$t = $transforms[$i];
// Make sure the transform has an ID.
$t = Transform::createOrLoad($t->transfFrom, $t->transfTo);
$md = Model::factory('ModelDescription')->create();
$md->modelId = $model->id;
$md->inflectionId = $inflId;
$md->variant = $variant;
$md->applOrder = $order++;
$md->isLoc = false;
$md->recommended = false;
$md->transformId = $t->id;
$md->accentShift = $accentShift;
$md->vowel = $accentedVowel;
$md->save();
}
$variant++;
}
}
示例3: die
if (!text_validateAlphabet($form, "aăâbcdefghiîjklmnopqrsștțuvwxyz'")) {
die("Illegal characters in form {$form}\n");
}
$transforms = text_extractTransforms($baseForm, $form, $model->modelType == 'P');
assert(count($transforms) >= 2);
// Split off the last transform: it indicates the accent shift
$accentShift = array_pop($transforms);
if ($accentShift != UNKNOWN_ACCENT_SHIFT && $accentShift != NO_ACCENT_SHIFT) {
$accentedVowel = array_pop($transforms);
} else {
$accentedVowel = '';
}
//foreach ($transforms as $t) {
// print $t->toString() . ' ';
//}
//print "$accentShift\n";
// Reverse the transforms array. At the same time, save the transforms.
$newT = array();
for ($i = count($transforms) - 1; $i >= 0; $i--) {
$t = $transforms[$i];
$newT[] = Transform::createOrLoad($t->from, $t->to);
}
$transforms = $newT;
foreach ($transforms as $i => $t) {
$md = ModelDescription::create($model->id, $inflId, $variant, $i, $t->id, $accentShift, $accentedVowel);
$md->save();
}
}
$numModels++;
}
print "{$numModels} models migrated from dmlr_models.\n";