diff --git a/mathparse/mathwords.py b/mathparse/mathwords.py index e9d1336..c9d4664 100644 --- a/mathparse/mathwords.py +++ b/mathparse/mathwords.py @@ -11,7 +11,8 @@ 'DUT': { 'prefix_unary_operators': { 'vierkantswortel van': 'sqrt', - 'wortel van': 'sqrt' + 'wortel van': 'sqrt', + 'logaritme van': 'log' }, 'postfix_unary_operators': { 'kwadraat': '^ 2' @@ -66,7 +67,9 @@ 'ENG': { 'prefix_unary_operators': { 'square root of': 'sqrt', - 'negative': 'neg' + 'negative': 'neg', + 'logarithm of': 'log', + 'log of': 'log' }, 'postfix_unary_operators': { 'squared': '^ 2', @@ -120,7 +123,8 @@ }, 'FRE': { 'prefix_unary_operators': { - 'racine carrée de': 'sqrt' + 'racine carrée de': 'sqrt', + 'logarithme de': 'log' }, 'postfix_unary_operators': { 'au carré': '^ 2', @@ -180,7 +184,8 @@ 'GER': { 'prefix_unary_operators': { 'Quadratwurzel von': 'sqrt', - 'Wurzel von': 'sqrt' + 'Wurzel von': 'sqrt', + 'Logarithmus von': 'log' }, 'postfix_unary_operators': { 'quadriert': '^ 2', @@ -239,7 +244,8 @@ }, 'GRE': { 'prefix_unary_operators': { - 'τετραγωνική ρίζα του': 'sqrt' + 'τετραγωνική ρίζα του': 'sqrt', + 'λογάριθμος του': 'log' }, 'postfix_unary_operators': { 'στο τετράγωνο': '^ 2', @@ -295,7 +301,8 @@ }, 'ITA': { 'prefix_unary_operators': { - 'radice quadrata di': 'sqrt' + 'radice quadrata di': 'sqrt', + 'logaritmo di': 'log' }, 'postfix_unary_operators': { 'al quadrato': '^ 2', @@ -350,7 +357,8 @@ }, 'MAR': { 'prefix_unary_operators': { - 'वर्गमूल': 'sqrt' + 'वर्गमूल': 'sqrt', + 'लॉगरिथम': 'log' }, 'postfix_unary_operators': { 'वर्ग': '^ 2', @@ -407,7 +415,8 @@ 'RUS': { 'prefix_unary_operators': { 'квадратный корень из': 'sqrt', - 'корень из': 'sqrt' + 'корень из': 'sqrt', + 'логарифм': 'log' }, 'postfix_unary_operators': { 'в квадрате': '^ 2', @@ -469,7 +478,8 @@ }, 'POR': { 'prefix_unary_operators': { - 'raiz quadrada de': 'sqrt' + 'raiz quadrada de': 'sqrt', + 'logaritmo de': 'log' }, 'postfix_unary_operators': { 'ao quadrado': '^ 2', @@ -524,7 +534,8 @@ 'UKR': { 'prefix_unary_operators': { 'квадратний корінь з': 'sqrt', - 'корінь з': 'sqrt' + 'корінь з': 'sqrt', + 'логарифм': 'log' }, 'postfix_unary_operators': { 'у квадраті': '^ 2', @@ -586,7 +597,8 @@ }, 'ESP': { 'prefix_unary_operators': { - 'raiz cuadrada de': 'sqrt' + 'raiz cuadrada de': 'sqrt', + 'logaritmo de': 'log' }, 'postfix_unary_operators': { 'al cuadrado': '^ 2', @@ -641,7 +653,8 @@ }, 'THA': { 'prefix_unary_operators': { - 'สแควรูท': 'sqrt' + 'สแควรูท': 'sqrt', + 'ลอการิทึม': 'log' }, 'postfix_unary_operators': { 'ยกกำลังสอง': '^ 2', @@ -698,7 +711,8 @@ 'prefix_unary_operators': { '平方根': 'sqrt', '开方': 'sqrt', - '负': 'neg' + '负': 'neg', + '对数': 'log' }, 'postfix_unary_operators': { '平方': '^ 2', diff --git a/tests/test_unary_operations.py b/tests/test_unary_operations.py index b0eeb82..f71d341 100644 --- a/tests/test_unary_operations.py +++ b/tests/test_unary_operations.py @@ -41,3 +41,98 @@ def test_negative_number(self): result = mathparse.parse('-4 + 2') self.assertEqual(result, -2) + + def test_log_symbolic(self): + result = mathparse.parse('log 100') + + self.assertEqual(result, 2.0) + + def test_log_symbolic_with_parenthesis(self): + result = mathparse.parse('log(1000)') + + self.assertEqual(result, 3.0) + + def test_log_english(self): + result = mathparse.parse('logarithm of 100', language='ENG') + + self.assertEqual(result, 2.0) + + def test_log_of_english(self): + result = mathparse.parse('log of 1000', language='ENG') + + self.assertEqual(result, 3.0) + + def test_log_french(self): + result = mathparse.parse('logarithme de 100', language='FRE') + + self.assertEqual(result, 2.0) + + def test_log_german(self): + result = mathparse.parse('Logarithmus von 100', language='GER') + + self.assertEqual(result, 2.0) + + def test_log_spanish(self): + result = mathparse.parse('logaritmo de 100', language='ESP') + + self.assertEqual(result, 2.0) + + def test_log_italian(self): + result = mathparse.parse('logaritmo di 100', language='ITA') + + self.assertEqual(result, 2.0) + + def test_log_portuguese(self): + result = mathparse.parse('logaritmo de 100', language='POR') + + self.assertEqual(result, 2.0) + + def test_log_russian(self): + result = mathparse.parse('логарифм 100', language='RUS') + + self.assertEqual(result, 2.0) + + def test_log_ukrainian(self): + result = mathparse.parse('логарифм 100', language='UKR') + + self.assertEqual(result, 2.0) + + def test_log_dutch(self): + result = mathparse.parse('logaritme van 100', language='DUT') + + self.assertEqual(result, 2.0) + + def test_log_greek(self): + result = mathparse.parse('λογάριθμος του 100', language='GRE') + + self.assertEqual(result, 2.0) + + def test_log_thai(self): + result = mathparse.parse('ลอการิทึม 100', language='THA') + + self.assertEqual(result, 2.0) + + def test_log_chinese(self): + result = mathparse.parse('对数 100', language='CHI') + + self.assertEqual(result, 2.0) + + def test_log_marathi(self): + result = mathparse.parse('लॉगरिथम 100', language='MAR') + + self.assertEqual(result, 2.0) + + def test_log_in_expression(self): + result = mathparse.parse('log 100 * 2') + + self.assertEqual(result, 4.0) + + def test_log_with_addition(self): + result = mathparse.parse('log 100 + log 1000') + + self.assertEqual(result, 5.0) + + def test_log_with_power(self): + result = mathparse.parse('(log 100) ^ 2') + + self.assertEqual(result, 4.0)