Exemple #1
0
def collect_normative_stances(stances):
    """Filters a given list of stances to contain only those that are normative.
    
    Arguments:
        stances: the list of stances to filter.
        
    Returns:
        The filtered list with duplicates removed.
    """
    filter_fun = lambda stance: normative_stance(stance)
    norms = filter(filter_fun, stances)
    return util.remove_duplicates(norms) if norms else []
Exemple #2
0
    def test_remove_duplicates(self):
        """Verify only the intersection of the list is included."""
        stance = Stance()
        stance.issue = "Test"
        stance.side = outcomes.PRO

        stance2 = Stance()
        stance2.issue = "Something different"
        stance2.side = outcomes.PRO

        data = [stance, stance, stance2, stance2, stance, stance2, stance]
        result = util.remove_duplicates(data)

        self.assertEquals(len(result), 2)
        self.assertTrue(stance in result)
        self.assertTrue(stance2 in result)