def normaliser(): """ Returns default normaliser, already configured. """ n = NormalisationRuleEngine() n.load_rules(os.path.join(os.path.split(__file__)[0], 'rules', 'normalisation')) return n
def normaliser(): """ Returns default normaliser, already configured. """ n = NormalisationRuleEngine() n.load_rules( os.path.join(os.path.split(__file__)[0], 'rules', 'normalisation')) return n
def testBadErrors(self): r = NormalisationRuleEngine() try: r.load_rules(os.path.join(os.path.dirname(__file__), 'test_normalisation_rules_malformed/')) except RuleLoadErrors as e: self.assertEqual(len(e.errors), 12, "These errors were raised: " + str(e)) else: self.fail('No exceptions were raised/caught')
def testBadErrors(self): r = NormalisationRuleEngine() try: r.load_rules(os.path.join(os.path.dirname(__file__), 'test_normalisation_rules_malformed/')) except RuleLoadErrors as e: self.assertEquals(len(e.errors), 12, "These errors were raised: " + str(e)) else: self.fail('No exceptions were raised/caught')
def testTag(self): e = NormalisationRuleEngine() e.load_rules(os.path.join(os.path.dirname(__file__), 'test_normalisation_rules')) t = Timex(type='date') e.annotate([[('We', 'POS', set()), ('took', 'POS', set()), ('a', 'POS', set()), ('plane', 'POS', set()), ('on', 'POS', set()), ('the', 'POS', set()), ('06', 'POS', {t}), ('th', 'POS', {t}), ('January', 'POS', {t}), ('1996', 'POS', {t}), ('to', 'POS', set()), ('Atlanta', 'POS', set())]], '') self.assertEquals(t.value, '19960106')
def testTag(self): e = NormalisationRuleEngine() e.load_rules(os.path.join(os.path.dirname(__file__), 'test_normalisation_rules')) t = Timex(type='date') e.annotate([[('We', 'POS', set()), ('took', 'POS', set()), ('a', 'POS', set()), ('plane', 'POS', set()), ('on', 'POS', set()), ('the', 'POS', set()), ('06', 'POS', {t}), ('th', 'POS', {t}), ('January', 'POS', {t}), ('1996', 'POS', {t}), ('to', 'POS', set()), ('Atlanta', 'POS', set())]], '') self.assertEqual(t.value, '19960106')