示例#1
0
def _get_raw_dictionary_item(course, word, is_in_target_language):
    """
        Find the matching raw dictionary item for a word.
    """
    dictionary_item = list(
        filter(
            lambda item: clean_word(item.word).lower() == clean_word(word).lower(
            ) and item.is_in_target_language == is_in_target_language,
            course.dictionary))

    return dictionary_item[0] if dictionary_item else None
示例#2
0
 def test_weird_english_posessive(self):
     assert clean_word("cats'") == "cats'"
示例#3
0
 def test_removes_exclamation_mark(self):
     assert clean_word("ba-ar!") == "ba-ar"
示例#4
0
 def test_doesnt_remove_parts_of_word_2(self):
     assert clean_word("L'Hospitalet") == "L'Hospitalet"
示例#5
0
 def test_doesnt_remove_parts_of_word_1(self):
     assert clean_word("ba-ar") == "ba-ar"
示例#6
0
 def test_removes_comma(self):
     assert clean_word("foo,") == "foo"
示例#7
0
 def test_removes_parentheses(self):
     assert clean_word("(foo") == "foo"
示例#8
0
 def test_empty_string(self):
     assert clean_word("") == ""