Esempio n. 1
0
    def parse_fraction(self, data):
        """finds and confidence scores a fraction"""
        is_fraction, value = self.is_fraction(data)
        if is_fraction:
            fraction_confidence = 100

            # for every character in the data other than the /, we lower
            # the confidence a bit. Fractions are USUALLY short
            for char in data:
                if char != "/":
                    fraction_confidence -= 3

            # if the fraction isn't solve-able, we lower the confidence
            # significantly it might "technically" be a fraction made up
            # of roman numerals, etc.
            if EquationParser in self.config.enabled_modules:
                eqp = EquationParser(self.config)
                if not eqp.solve_equation(eqp.auto_float(data)):
                    fraction_confidence -= 40

            return self.result("Fraction", fraction_confidence, value)
Esempio n. 2
0
 def setUp(self):
     self.ep = EquationParser(TestConfig)