Ejemplo n.º 1
0
def test_vector_space_wrapper_filter():
    wrap = VectorSpaceWrapper(frame=TEST_FRAME)
    wrap.load()
    ok_('/c/pl/kombinacja' in wrap.similar_terms('/c/en/nordic_combined', filter='/c/pl',
                                                 limit=1).index)

    ok_('/c/en/present' in wrap.similar_terms('/c/en/gift', filter='/c/en/present', limit=1).index)
def test_similar_terms_filter():
    vectors = VectorSpaceWrapper(frame=TEST_FRAME)
    vectors.load()
    ok_('/c/pl/kombinacja' in vectors.similar_terms(
        '/c/en/nordic_combined', filter='/c/pl', limit=1).index)

    ok_('/c/en/present' in vectors.similar_terms(
        '/c/en/gift', filter='/c/en/present', limit=1).index)
Ejemplo n.º 3
0
def test_similar_terms_filter(multi_ling_frame):
    vectors = VectorSpaceWrapper(frame=multi_ling_frame)
    vectors.load()
    assert ('/c/pl/kombinacja'
            in vectors.similar_terms('/c/en/nordic_combined',
                                     filter='/c/pl',
                                     limit=1).index)

    assert ('/c/en/present' in vectors.similar_terms('/c/en/gift',
                                                     filter='/c/en/present',
                                                     limit=1).index)
def test_similar_terms():
    """
    Check if VectorSpaceWrapper's index is sorted and its elements are concepts.
    """
    vectors = VectorSpaceWrapper(frame=TEST_FRAME)
    vectors.load()
    ok_('/c/en/figure skating' in vectors.similar_terms('/c/en/figure skating',
                                                        limit=3).index)
    ok_('/c/en/figure skater' in vectors.similar_terms('/c/en/figure skating',
                                                       limit=3).index)
    ok_('/c/en/figure' in vectors.similar_terms('/c/en/figure skating',
                                                limit=3).index)
Ejemplo n.º 5
0
def test_similar_terms(simple_frame):
    """
    Check if VectorSpaceWrapper's index is sorted and its elements are concepts.
    """
    vectors = VectorSpaceWrapper(frame=simple_frame)
    vectors.load()
    assert ('/c/en/figure skating'
            in vectors.similar_terms('/c/en/figure skating', limit=3).index)
    assert ('/c/en/figure skater'
            in vectors.similar_terms('/c/en/figure skating', limit=3).index)
    assert ('/c/en/figure' in vectors.similar_terms('/c/en/figure skating',
                                                    limit=3).index)
def test_similar_terms_filter():
    vectors = VectorSpaceWrapper(frame=TEST_FRAME)
    vectors.load()
    ok_(
        '/c/pl/kombinacja'
        in vectors.similar_terms('/c/en/nordic_combined', filter='/c/pl', limit=1).index
    )

    ok_(
        '/c/en/present'
        in vectors.similar_terms('/c/en/gift', filter='/c/en/present', limit=1).index
    )
def test_similar_terms():
    """
    Check if VectorSpaceWrapper's index is sorted and its elements are concepts.
    """
    vectors = VectorSpaceWrapper(frame=TEST_FRAME)
    vectors.load()
    ok_(
        '/c/en/figure skating'
        in vectors.similar_terms('/c/en/figure skating', limit=3).index
    )
    ok_(
        '/c/en/figure skater'
        in vectors.similar_terms('/c/en/figure skating', limit=3).index
    )
    ok_('/c/en/figure' in vectors.similar_terms('/c/en/figure skating', limit=3).index)
def test_missing_language():
    vectors = VectorSpaceWrapper(frame=TEST_FRAME)
    vectors.load()

    # The frame contains no Esperanto, of course, so the out-of-vocabulary
    # mechanism will fail. We should simply get no results, not crash.
    similarity = vectors.similar_terms('/c/eo/ekzemplo')
    eq_(len(similarity), 0)
def test_missing_language():
    vectors = VectorSpaceWrapper(frame=TEST_FRAME)
    vectors.load()

    # The frame contains no Esperanto, of course, so the out-of-vocabulary
    # mechanism will fail. We should simply get no results, not crash.
    similarity = vectors.similar_terms('/c/eo/ekzemplo')
    eq_(len(similarity), 0)
Ejemplo n.º 10
0
def test_vector_space_wrapper():
    """
    Check if VectorSpaceWrapper's index is sorted and its elements are concepts.
    """
    wrap = VectorSpaceWrapper(frame=TEST_FRAME)
    wrap.load()
    ok_(all(is_term(label) for label in wrap.frame.index))
    ok_(wrap.frame.index.is_monotonic_increasing)

    # test there are no transformations to raw terms other than adding the english tag
    ok_('/c/en/figure skater' in wrap.frame.index) # no underscore
    ok_('/c/en/Island' in wrap.frame.index) # no case folding

    # test index_prefix_range
    ok_(wrap.index_prefix_range('/c/en/figure') == (3, 6))
    ok_(wrap.index_prefix_range('/c/en/skating') == (0, 0))

    # test_similar_terms
    ok_('/c/en/figure skating' in wrap.similar_terms('/c/en/figure skating', limit=3).index)
    ok_('/c/en/figure skater' in wrap.similar_terms('/c/en/figure skating', limit=3).index)
    ok_('/c/en/figure' in wrap.similar_terms('/c/en/figure skating', limit=3).index)