def test_get_numbers_from_tokens_works_with_magnitude_words(self): tokens = [Token(x) for x in ['one', 'million', '7', 'thousand']] numbers = TableQuestionKnowledgeGraph._get_numbers_from_tokens(tokens) assert numbers == [('1000000', 'one million'), ('7000', '7 thousand')]
def test_get_numbers_from_tokens_works_for_units(self): tokens = [Token(x) for x in ['1ghz', '3.5mm', '-2m/s']] numbers = TableQuestionKnowledgeGraph._get_numbers_from_tokens(tokens) assert numbers == [('1', '1ghz'), ('3.500', '3.5mm'), ('-2', '-2m/s')]
def test_get_numbers_from_tokens_works_for_ordinal_and_cardinal_numbers( self): tokens = [Token(x) for x in ['one', 'five', 'Seventh']] numbers = TableQuestionKnowledgeGraph._get_numbers_from_tokens(tokens) assert numbers == [('1', 'one'), ('5', 'five'), ('7', 'Seventh')]
def test_get_numbers_from_tokens_works_for_months(self): tokens = [Token(x) for x in ['January', 'March', 'october']] numbers = TableQuestionKnowledgeGraph._get_numbers_from_tokens(tokens) assert numbers == [('1', 'January'), ('3', 'March'), ('10', 'october')]
def test_get_numbers_from_tokens_works_for_arabic_numerals(self): tokens = [Token(x) for x in ['7', '1.0', '-20']] numbers = TableQuestionKnowledgeGraph._get_numbers_from_tokens(tokens) assert numbers == [('7', '7'), ('1.000', '1.0'), ('-20', '-20')]