def runTest(self): # empty list self.assertEqual(neg.getNegationArray([], 4, True), [], 'Failed to deal with empty list') # untagged - processes as normal self.assertTrue(neg.getNegationArray(STR_UNTAGGED.split(), 4, True), 'Unable to process untagged doc') # string should raise an error self.assertRaises(AssertionError, neg.getNegationArray, STR_UNTAGGED, 4, True)
def runTest(self): # loop increasing window sizes negatedsums = [] for i in range(1,6): A = neg.getNegationArray(STR_WINDOW.split(), i, False) negatedsums.append(sum(A)) for i in range(4): self.assertTrue(negatedsums[i] < negatedsums[i+1], 'Something wrong with window size %d'%i)
def runTest(self): # loop increasing window sizes negatedsums = [] for i in range(1,6): A = neg.getNegationArray(STR_WINDOW.split(), i, False) negatedsums.append(sum(A)) print str(negatedsums) for i in range(4): self.assertTrue(negatedsums[i] < negatedsums[i+1], 'Something wrong with window size %d'%i)
def test_window(): # loop increasing window sizes negatedsums = [] for i in range(1, 6): A = neg.getNegationArray(STR_WINDOW.split(), i, False) negatedsums.append(sum(A)) for i in range(4): assert negatedsums[i] < negatedsums[i + 1]
def runTest(self): # no negation A = neg.getNegationArray(STR_NONEGATION.split(), 4, True) self.assertEqual(sum(A), 0, 'No negation string failed') # simple negation A = neg.getNegationArray(STR_NEGATION.split(), 4, True) self.assertTrue(sum(A) > 0, 'Negation algo failed on STR_NEGATION') # double negation A = neg.getNegationArray(STR_DOUBLE.split(), 4, True) self.assertTrue(sum(A) > 0, 'Negation algo failed on STR_DOUBLE') # pseudo A = neg.getNegationArray(STR_PSEUDO.split(), 4, True) self.assertTrue(sum(A) == 0, 'Negation algo failed on STR_PSEUDO') # other tag A = neg.getNegationArray(STR_OTHERTAG.split(), 4, True) self.assertTrue(sum(A) > 0, 'Negation algo failed on STR_OTHERTAG')
def runTest(self): # no negation A = neg.getNegationArray(STR_NONEGATION.split(), 4, True) self.assertEqual(sum(A), 0, 'No negation string failed') # simple negation A = neg.getNegationArray(STR_NEGATION.split(), 4, True) self.assertTrue(sum(A)>0, 'Negation algo failed on STR_NEGATION') # double negation A = neg.getNegationArray(STR_DOUBLE.split(), 4, True) self.assertTrue(sum(A)>0, 'Negation algo failed on STR_DOUBLE') # pseudo A = neg.getNegationArray(STR_PSEUDO.split(), 4, True) self.assertTrue(sum(A)==0, 'Negation algo failed on STR_PSEUDO') # other tag A = neg.getNegationArray(STR_OTHERTAG.split(), 4, True) self.assertTrue(sum(A)>0, 'Negation algo failed on STR_OTHERTAG')
def test_negation_detection_notfound(sentence): assert sum(neg.getNegationArray(sentence.split(), 4)) == 0
def test_edge_cases(): # empty list assert neg.getNegationArray([], 4) == [] # untagged - processes as normal assert neg.getNegationArray(STR_UNTAGGED.split(), 4)