本文整理汇总了PHP中Feature::make_feature方法的典型用法代码示例。如果您正苦于以下问题:PHP Feature::make_feature方法的具体用法?PHP Feature::make_feature怎么用?PHP Feature::make_feature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Feature
的用法示例。
在下文中一共展示了Feature::make_feature方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
function import()
{
try {
$page = isset($_GET['page']) ? $_GET['page'] : null;
if ($page == 0) {
del_feature();
}
$results = get_writing($page);
$size = sizeof($results);
foreach ($results as $r) {
$f = new Feature();
$w = json_decode($r->writing);
$char_id = $r->char_id;
$features = $f->make_feature($w);
//获取特征
$dic = new Dictionary();
$dict_feature = $dic->get_feature($char_id);
//获取数据库中已存的特征值
$dict_feature = isset($dict_feature) ? json_decode($dict_feature) : null;
$t = new Trainer();
$t->train($features, $dict_feature);
$c = new Character();
$first_stroke_type = $c->get_first_stroke_type($w);
//首笔的笔画类型(横竖撇点折)
$int_strokes = sizeof($w->s);
//笔画数
$dic->update_character($char_id, json_encode($t->train_features), $int_strokes, $first_stroke_type);
}
if ($size > 0) {
echo "<meta HTTP-EQUIV=REFRESH CONTENT='5;URL=import.php?page=" . ($page + 1) . "'>";
} else {
echo "导入完成";
}
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例2: learn
function learn(&$ret, &$writing, $char_id, $user_id)
{
try {
$c = new Character();
$w = $c->create_sparse_writing($writing);
//骨架化笔画
$f = new Feature();
$features = $f->make_feature($w);
//获取特征
$dic = new Dictionary();
$dic->add_writing($char_id, $w, $user_id);
//添加笔迹
$dict_feature = $dic->get_feature($char_id);
//获取数据库中已存的特征值
$dict_feature = isset($dict_feature) ? json_decode($dict_feature) : null;
$t = new Trainer();
$t->train($features, $dict_feature);
$first_stroke_type = $c->get_first_stroke_type($w);
//首笔的笔画类型(横竖撇点折)
$int_strokes = sizeof($w->s);
//笔画数
$dic->update_character($char_id, json_encode($t->train_features), $int_strokes, $first_stroke_type);
$ret->msgno = MSG_OK;
$ret->msg = MSG_OK_LEARN;
} catch (Exception $e) {
$ret->msgno = MSG_ERR;
$ret->msg = $e->getMessage();
}
}