diff --git a/mycroft/skills/wolfram_alpha/__init__.py b/mycroft/skills/wolfram_alpha/__init__.py index 83a6b0d64b..08b1bbdfe2 100644 --- a/mycroft/skills/wolfram_alpha/__init__.py +++ b/mycroft/skills/wolfram_alpha/__init__.py @@ -171,9 +171,9 @@ class WolframAlphaSkill(MycroftSkill): if "|" in result: # Assuming "|" indicates a list of items verb = ":" - result = self.__process_wolfram_string(result) + result = self.process_wolfram_string(result) input_interpretation = \ - self.__process_wolfram_string(input_interpretation) + self.process_wolfram_string(input_interpretation) response = "%s %s %s" % (input_interpretation, verb, result) self.speak(response) @@ -188,7 +188,7 @@ class WolframAlphaSkill(MycroftSkill): return None @staticmethod - def __process_wolfram_string(text): + def process_wolfram_string(text): # Remove extra whitespace text = re.sub(r" \s+", r" ", text) @@ -196,7 +196,7 @@ class WolframAlphaSkill(MycroftSkill): text = re.sub(r" \| ", r", ", text) # Convert newlines to commas - text = re.sub(r"\n", r",. ", text) + text = re.sub(r"\n", r", ", text) # Convert !s to factorial text = re.sub(r"!", r",factorial", text) diff --git a/test/skills/wolfram_alpha/__init__.py b/test/skills/wolfram_alpha/__init__.py index 2f04bd85d2..97d60495d0 100644 --- a/test/skills/wolfram_alpha/__init__.py +++ b/test/skills/wolfram_alpha/__init__.py @@ -48,3 +48,19 @@ class WolframAlphaTest(unittest.TestCase): def test_invalid_pod(self): res = self.create_result("InvalidTitle", "Test") self.assertEquals(WolframAlphaSkill().get_result(res), None) + + def test_whitespace_process(self): + self.assertEquals(WolframAlphaSkill().process_wolfram_string + ("Test string"), "Test string") + + def test_pipe_process(self): + self.assertEquals(WolframAlphaSkill().process_wolfram_string + ("Test | string"), "Test, string") + + def test_newline_process(self): + self.assertEquals(WolframAlphaSkill().process_wolfram_string + ("Test\nstring"), "Test, string") + + def test_factorial_process(self): + self.assertEquals(WolframAlphaSkill().process_wolfram_string + ("Test!"), "Test,factorial")