Example #1
0
def test_suffix_before_prefix():
    string = "w o r - d h u + s u f"
    word, prefix, stem, suffix = split_word_components(string)
    assert word == []
    assert stem == []
    assert prefix == []
    assert suffix == []
Example #2
0
def test_invalid_word_multiple_affixes():
    string = "h e - - l o +"
    word, prefix, stem, suffix = split_word_components(string)
    assert word == []
    assert stem == []
    assert prefix == []
    assert suffix == []
Example #3
0
def test_split_prefix_and_suffix():
    string = "p r e + s t e m - s u f"
    word, prefix, stem, suffix = split_word_components(string)
    assert word == ['p', 'r', 'e', '+', 's', 't', 'e', 'm', '-', 's', 'u', 'f']
    assert prefix == [['p', 'r', 'e', '+']]
    assert stem == ['s', 't', 'e', 'm']
    assert suffix == [['-', 's', 'u', 'f']]
Example #4
0
def test_split_suffix():
    string = "w o r d - w i n"
    word, prefix, stem, suffix = split_word_components(string)
    assert word == ['w', 'o', 'r', 'd', '-', 'w', 'i', 'n']
    assert prefix == []
    assert suffix == [['-', 'w', 'i', 'n']]
    assert stem == ['w', 'o', 'r', 'd']
Example #5
0
def test_stem_only():
    string = "w o r d"
    word, prefix, stem, suffix = split_word_components(string)
    assert word == ['w', 'o', 'r', 'd']
    assert prefix == []
    assert suffix == []
    assert stem == word
Example #6
0
def test_split_prefix():
    string = "w o r + d w i"
    word, prefix, stem, suffix = split_word_components(string)
    assert word == ['w', 'o', 'r', '+', 'd', 'w', 'i']
    assert prefix == [['w', 'o', 'r', '+']]
    assert suffix == []
    assert stem == ['d', 'w', 'i']
Example #7
0
def run_test_on_strings(input_list, output_list, object):
    for i in range(len(input_list)):
        string = input_list[i]
        word_as_list, prefix_as_list, stem_as_list, suffix_as_list = \
            split_word_components(string)
        proceed, preprocessed = \
            preprocess(word_as_list, prefix_as_list, stem_as_list, suffix_as_list, object)
        if proceed:
            assert output_list[i] == postprocess(object.step(preprocessed), object)
        else:
            assert output_list[i] == "".join(preprocessed)
Example #8
0
def test_multiple_prefixes():
    string = "w o r + d a n + o t + e a u w p q u a"
    word, prefix, stem, suffix = split_word_components(string)
    assert word == [
        'w', 'o', 'r', '+', 'd', 'a', 'n', '+', 'o', 't', '+', 'e', 'a', 'u',
        'w', 'p', 'q', 'u', 'a'
    ]
    assert prefix == [['w', 'o', 'r', '+'], ['d', 'a', 'n', '+'],
                      ['o', 't', '+']]
    assert stem == ['e', 'a', 'u', 'w', 'p', 'q', 'u', 'a']
    assert suffix == []