Example #1
0
def test_add_one_word():
    encoder = WordEncoder()

    encoder.add_word('HTE')
    encoded_dict = encoder.get_dict()
    assert encoded_dict['....-.'] == 1
    encoder.add_word('HTE')
    encoded_dict = encoder.get_dict()
    assert encoded_dict['....-.'] == 2
    assert len(encoder.get_list()) == 1
def test_add_word_list(context):
    encoder = WordEncoder(context)
    encoded_dict = encoder.get_dict()
    encoder.add_word_list(['HTE', 'EE'])
    assert encoded_dict['....-.'].word == '....-.'
    assert encoded_dict['..'].word == '..'
    assert len(encoder.get_list()) == 2
Example #3
0
def test_add_word_list():
    encoder = WordEncoder()
    encoder.add_word_list(['HTE', 'EE'])
    encoded_dict = encoder.get_dict()
    assert encoded_dict['....-.'] == 1
    assert encoded_dict['..'] == 1
    assert len(encoder.get_list()) == 2
def test_add_one_word(context):
    encoder = WordEncoder(context)
    encoded_dict = encoder.get_dict()

    encoder.add_word('HTE')
    word = encoded_dict['....-.']
    assert word.duplicates == 1
    assert word.word == '....-.'
    assert len(encoder) == 1
def test_add_two_word_with_screening(context):
    encoder = WordEncoder(context, use_screening=True)
    encoded_dict = encoder.get_dict()

    encoder.add_word('HTE')
    assert str(encoded_dict['....-.']) == '....-.'

    encoder.add_word('K')
    assert '-.-' not in encoded_dict

    assert len(encoder) == 1
def test_add_two_word_with_duplicates(context):
    encoder = WordEncoder(context)
    encoded_dict = encoder.get_dict()

    encoder.add_word('HTE')
    assert str(encoded_dict['....-.']) == '....-.'

    encoder.add_word('HTE')
    assert str(encoded_dict['....-.']) == '....-.#2'

    assert len(encoder) == 1
def test_add_two_words(context):
    encoder = WordEncoder(context)
    encoded_dict = encoder.get_dict()

    encoder.add_word('HTE')
    assert str(encoded_dict['....-.']) == '....-.'

    encoder.add_word('ET')
    assert str(encoded_dict['.-']) == '.-'

    assert len(encoder) == 2
def test_add_one_word_with_sep(context):
    encoder = WordEncoder(context, sep='|')
    encoded_dict = encoder.get_dict()
    encoder.add_word('HTE')
    assert encoded_dict['....|-|.'].word == '....|-|.'
Example #9
0
def test_add_one_word_with_alphabet():
    morse = MorseAlphabet()
    encoder = WordEncoder(sep='|', alphabet=morse)
    encoder.add_word('HTE')
    encoded_dict = encoder.get_dict()
    assert encoded_dict['....|-|.'] == 1