def test_TopN1(self):
     counterHashMap = CounterHashMap()
     counterHashMap.put("item1")
     counterHashMap.put("item2")
     counterHashMap.put("item3")
     counterHashMap.put("item1")
     counterHashMap.put("item2")
     counterHashMap.put("item1")
     self.assertEquals("item1", counterHashMap.topN(1)[0][1])
     self.assertEquals("item2", counterHashMap.topN(2)[1][1])
     self.assertEquals("item3", counterHashMap.topN(3)[2][1])
 def test_TransitionWithName(self):
     transitionCounts = CounterHashMap()
     for state in self.stateList:
         transitions = self.fsm.getTransitions(state)
         for transition in transitions:
             transitionCounts.put(transition.withName())
     topList = transitionCounts.topN(5)
     self.assertEqual(None, topList[0][1])
     self.assertEqual(52, topList[0][0])
     self.assertEqual("^DB+VERB+CAUS", topList[1][1])
     self.assertEqual(33, topList[1][0])
     self.assertEqual("^DB+VERB+PASS", topList[2][1])
     self.assertEqual(31, topList[2][0])
     self.assertEqual("A3PL", topList[3][1])
     self.assertEqual(28, topList[3][0])
     self.assertEqual("LOC", topList[4][1])
     self.assertEqual(24, topList[4][0])
 def test_TransitionWith(self):
     transitionCounts = CounterHashMap()
     for state in self.stateList:
         transitions = self.fsm.getTransitions(state)
         for transition in transitions:
             transitionCounts.put(transition.__str__())
     topList = transitionCounts.topN(5)
     self.assertEqual("0", topList[0][1])
     self.assertEqual(111, topList[0][0])
     self.assertEqual("lAr", topList[1][1])
     self.assertEqual(37, topList[1][0])
     self.assertEqual("DHr", topList[2][1])
     self.assertEqual(28, topList[2][0])
     self.assertEqual("Hn", topList[3][1])
     self.assertEqual(24, topList[3][0])
     self.assertEqual("lArH", topList[4][1])
     self.assertEqual(23, topList[4][0])
 def test_TopN2(self):
     counterHashMap = CounterHashMap()
     for i in range(1000):
         counterHashMap.putNTimes(i, 2 * i + 2)
     self.assertEquals(990, counterHashMap.topN(10)[9][1])
     self.assertEquals(900, counterHashMap.topN(100)[99][1])