def test_isDecimal(self): testList = [(u"2.5", True), (u"2,5", True), (u"2,5,3", True), (u"2-5", False)] for t, gt in testList: self.assertEquals(NumberFormula._isDecimalNumber(t), gt, t.encode('utf-8'))
def test_apply(self): f = NumberFormula() for k in list(self.testDict.keys()): # print "Testing %s " % k testList = self.testDict[k] self.evaluateListValues(testList, f.apply)
def test_ordinal2word(self): testList = self.testDict["ordinal"] for i, (t, gt) in enumerate(testList): r = NumberFormula._ordinal2word([t], 0) self.assertEquals( gt.encode('utf-8'), r.encode('utf-8'), "%s is not %s" % (r.encode('utf-8'), gt.encode('utf-8')))
def test_isOrdinal(self): testList = [(u"1er", True), (u"1re", True), (u"1ère", True), (u"2e", True), (u"2ème", True), (u"Ier", True), (u"XIIème", True)] for t, gt in testList: self.assertEquals(NumberFormula._isOrdinalNumber(t), gt, t.encode('utf-8'))
def isOrdinalNumber(strWord, languageId): """Cross language check for ordinal number. """ bOrdinal = False if languageId == 0: if EnglishNumberFormula._isOrdinalNumber(strWord) or \ GermanNumberFormula._isOrdinalNumber(strWord) or \ FrenchNumberFormula._isOrdinalNumber(strWord): bOrdinal = True else: if languageId == FRENCH: bOrdinal = FrenchNumberFormula._isOrdinalNumber(strWord) elif languageId == GERMAN: bOrdinal = GermanNumberFormula._isOrdinalNumber(strWord) else: bOrdinal = EnglishNumberFormula._isOrdinalNumber(strWord) return bOrdinal
def test_isCardinal(self): testList = [("2", True), ("123", True), ("123.", False)] for t, gt in testList: self.assertEqual(NumberFormula._isCardinalNumber(t), gt, t)
def test_ordinal2word(self): testList = self.testDict["ordinal"] for i, (t, gt) in enumerate(testList): r = NumberFormula._ordinal2word([t], 0) self.assertEqual(gt, r, "%s is not %s" % (r, gt))
def test_isRoman(self): testList = [(u"V",False), (u"XII",True), (u"La", False)] for t, gt in testList: self.assertEquals(NumberFormula._isRomanNumber(t), gt, t.encode('utf-8'))
def test_isDecimal(self): testList = [(u"2.5",True), (u"2,5",True),(u"2,5,3",True), (u"2-5",False)] for t, gt in testList: self.assertEquals(NumberFormula._isDecimalNumber(t), gt, t.encode('utf-8'))
def test_isDecimal(self): testList = [("2.5", True), ("2,5", True), ("2,5,3", True), ("2-5", False)] for t, gt in testList: self.assertEqual(NumberFormula._isDecimalNumber(t), gt, t)
def test_isCardinal(self): testList = [(u"2",True),(u"123",True), (u"123.",False)] for t, gt in testList: self.assertEquals(NumberFormula._isCardinalNumber(t), gt, t.encode('utf-8'))
def test_ordinal2word(self): testList = self.testDict["ordinal"] for i, (t, gt) in enumerate(testList): r = NumberFormula._ordinal2word([t], 0) self.assertEquals(gt.encode('utf-8'), r.encode('utf-8'), "%s is not %s" % (r.encode('utf-8'), gt.encode('utf-8')))
def test_isTransition(self): testList = [(u"1.",True),(u"10.",True), (u"11.",False)] for t, gt in testList: self.assertEquals(NumberFormula._isTransitionNumber(t), gt, t.encode('utf-8'))
def test_isTransition(self): testList = [("1.", True), ("10.", True), ("11.", False)] for t, gt in testList: self.assertEqual(NumberFormula._isTransitionNumber(t), gt, t)
def test_isOrdinal(self): testList = [("1er", True), ("1re", True), ("1ère", True), ("2e", True), ("2ème", True), ("Ier", True), ("XIIème", True)] for t, gt in testList: self.assertEqual(NumberFormula._isOrdinalNumber(t), gt, t)
def test_isRoman(self): testList = [("V", False), ("XII", True), ("La", False)] for t, gt in testList: self.assertEqual(NumberFormula._isRomanNumber(t), gt, t)
def test_isOrdinal(self): testList = [(u"1er",True), (u"1re",True), (u"1ère",True), (u"2e",True), (u"2ème",True), (u"Ier",True), (u"XIIème",True)] for t, gt in testList: self.assertEquals(NumberFormula._isOrdinalNumber(t), gt, t.encode('utf-8'))