当前位置: 首页>>代码示例>>PHP>>正文


PHP Feature::make_feature方法代码示例

本文整理汇总了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();
    }
}
开发者ID:tianxang,项目名称:php-handwriting,代码行数:37,代码来源:import.php

示例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();
    }
}
开发者ID:tianxang,项目名称:php-handwriting,代码行数:29,代码来源:handwriting.php


注:本文中的Feature::make_feature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。