예제 #1
0
def test_dimensionality():
    feature_list = [
        (features.StrokeCount(), 1),
        (
            features.ConstantPointCoordinates(strokes=4,
                                              points_per_stroke=20,
                                              fill_empty_with=0),
            160,
        ),
        (
            features.ConstantPointCoordinates(strokes=0,
                                              points_per_stroke=20,
                                              fill_empty_with=0),
            60,
        ),
        (
            features.ConstantPointCoordinates(strokes=0,
                                              points_per_stroke=20,
                                              pen_down=False),
            40,
        ),
        (features.AspectRatio(), 1),
        (features.Width(), 1),
        (features.Height(), 1),
        (features.Time(), 1),
        (features.CenterOfMass(), 2),
    ]
    for feat, dimension in feature_list:
        assert feat.get_dimension() == dimension
예제 #2
0
def dimension_test():
    l = [(features.ConstantPointCoordinates(), 160),
         (features.FirstNPoints(), 162),  # TODO: Check
         (features.StrokeCount(), 1),
         (features.Ink(), 1)
         ]
    for alg, dimension in l:
        nose.tools.assert_equal(alg.get_dimension(), dimension)
예제 #3
0
def repr_and_str_test():
    l = [features.ConstantPointCoordinates(),
         features.FirstNPoints(),
         features.StrokeCount(),
         features.Ink()
         ]
    for alg in l:
        str(alg)
        repr(alg)
예제 #4
0
def test_dimension():
    algorithms = [
        (features.ConstantPointCoordinates(), 160),
        (features.FirstNPoints(), 162),  # TODO: Check
        (features.StrokeCount(), 1),
        (features.Ink(), 1),
    ]
    for algorithm, dimension in algorithms:
        assert algorithm.get_dimension() == dimension
예제 #5
0
def test_repr_and_str():
    algorithms = [
        features.ConstantPointCoordinates(),
        features.FirstNPoints(),
        features.StrokeCount(),
        features.Ink(),
    ]
    for algorithm in algorithms:
        str(algorithm)
        repr(algorithm)
예제 #6
0
def test_prepare_dataset():
    """Test create_ffiles.prepare_dataset."""
    dataset = []
    for i in range(200):
        dataset.append({
            "handwriting": th.get_symbol_as_handwriting(97705),
            "formula_id": 42
        })
    # dataset[-1]['handwriting'].formula_id = 42
    formula_id2index = {}
    formula_id2index[42] = 1
    feature_list = [features.StrokeCount()]
    is_traindata = False
    create_ffiles.prepare_dataset(dataset, formula_id2index, feature_list,
                                  is_traindata)
예제 #7
0
def feature_detection_test():
    l = [{'StrokeCount': None},
         {'ConstantPointCoordinates':
          [{'strokes': 4},
           {'points_per_stroke': 81},
           {'fill_empty_with': 0},
           {'pen_down': False}]
          }
         ]
    correct = [features.StrokeCount(),
               features.ConstantPointCoordinates(strokes=4,
                                                 points_per_stroke=81,
                                                 fill_empty_with=0,
                                                 pen_down=False)]
    feature_list = features.get_features(l)
    # TODO: Not only compare lengths of lists but actual contents.
    nose.tools.assert_equal(len(feature_list), len(correct))
예제 #8
0
파일: feature_test.py 프로젝트: lyqsr/hwrt
def features_detection_test():
    feature_queue = [{
        'StrokeCount': None
    }, {
        'ConstantPointCoordinates': [{
            'strokes': 4,
            'points_per_stroke': 20,
            'fill_empty_with': 0
        }]
    }]
    correct = [
        features.StrokeCount(),
        features.ConstantPointCoordinates(strokes=4,
                                          points_per_stroke=20,
                                          fill_empty_with=0)
    ]
    feature_list = features.get_features(feature_queue)
    # TODO: Not only compare lengths of lists but actual contents.
    nose.tools.assert_equal(len(feature_list), len(correct))
예제 #9
0
파일: feature_test.py 프로젝트: lyqsr/hwrt
def print_featurelist_test():
    """Test features.print_featurelist."""
    feature_list = [
        features.StrokeCount(),
        features.ConstantPointCoordinates(strokes=4,
                                          points_per_stroke=20,
                                          fill_empty_with=0),
        features.ConstantPointCoordinates(strokes=0,
                                          points_per_stroke=20,
                                          fill_empty_with=0),
        features.ConstantPointCoordinates(strokes=0,
                                          points_per_stroke=20,
                                          pen_down=False),
        features.AspectRatio(),
        features.Width(),
        features.Height(),
        features.Time(),
        features.CenterOfMass()
    ]
    features.print_featurelist(feature_list)
예제 #10
0
def test_feature_detection():
    queue = [
        {"StrokeCount": None},
        {
            "ConstantPointCoordinates": [
                {"strokes": 4},
                {"points_per_stroke": 81},
                {"fill_empty_with": 0},
                {"pen_down": False},
            ]
        },
    ]
    correct = [
        features.StrokeCount(),
        features.ConstantPointCoordinates(
            strokes=4, points_per_stroke=81, fill_empty_with=0, pen_down=False
        ),
    ]
    feature_list = features.get_features(queue)
    # TODO: Not only compare lengths of lists but actual contents.
    assert len(feature_list) == len(correct)
예제 #11
0
def test_features_detection():
    feature_queue = [
        {
            "StrokeCount": None
        },
        {
            "ConstantPointCoordinates": [{
                "strokes": 4,
                "points_per_stroke": 20,
                "fill_empty_with": 0
            }]
        },
    ]
    correct = [
        features.StrokeCount(),
        features.ConstantPointCoordinates(strokes=4,
                                          points_per_stroke=20,
                                          fill_empty_with=0),
    ]
    feature_list = features.get_features(feature_queue)
    # TODO: Not only compare lengths of lists but actual contents.
    assert len(feature_list) == len(correct)
예제 #12
0
def stroke_count_test():
    feature_list = [features.StrokeCount()]
    a = testhelper.get_symbol_as_handwriting(97705)
    nose.tools.assert_equal(a.feature_extraction(feature_list), [1])
예제 #13
0
def test_stroke_count():
    feature_list = [features.StrokeCount()]
    a = testhelper.get_symbol_as_handwriting(97705)
    assert a.feature_extraction(feature_list) == [1]