def test_escaping(self): texts = [ "Maradona", "El Diego", "El Diego ( el 10 )", "|()|", "æßðæßð", "\ hello \ ", "*", ] gm = GazetteManager() for text in texts: escaped = gm.escape_text(text) self.assertEqual(escaped.count("\Q"), len(text.split())) self.assertEqual(escaped.count("\E"), len(text.split()))
def _test_single_gazette(self, text=None): if text: gazette_item = GazetteItemFactory(text=text) else: gazette_item = GazetteItemFactory() gzmanager = GazetteManager() filepath = gzmanager.generate_stanford_gazettes_file() self.assertNotEqual(filepath, None) data = open(filepath).read().split("\n") self.assertEqual(len(data), 2) data = data[0].split("\t") self.assertEqual(len(data), 3) self.assertEqual(data[0], gzmanager.escape_text(gazette_item.text)) self.assertEqual(data[1], "{}{}".format(gzmanager._PREFIX, gazette_item.kind.name)) gazette_item.delete()