def test_MaxThreshold2(self): counterHashMap = CounterHashMap() for i in range(1000000): counterHashMap.put(randrange(100).__str__()) probability = counterHashMap.count(counterHashMap.max()) / 1000000.0 self.assertIsNotNone(counterHashMap.max(probability - 0.001)) self.assertIsNone(counterHashMap.max(probability + 0.001))
def test_MaxThreshold1(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.max(0.4999)) self.assertNotEquals("item1", counterHashMap.max(0.5001))
def test_Max(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.max())
def getMaximum(classLabels: list) -> str: """ Given an array of class labels, returns the maximum occurred one. PARAMETERS ---------- classLabels : list An array of class labels. RETURNS ------- str The class label that occurs most in the array of class labels (mod of class label list). """ frequencies = CounterHashMap() for label in classLabels: frequencies.put(label) return frequencies.max()
def nextWordPos(nextParseList: FsmParseList) -> str: _map = CounterHashMap() for i in range(nextParseList.size()): _map.put(nextParseList.getFsmParse(i).getPos()) return _map.max()