Exemplo n.º 1
0
 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()))
Exemplo n.º 2
0
 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()))
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
    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()