Пример #1
0
def _initialize_decision(decision, member, bill):
    """Initializes a decision object with information about the member and bill.
    Extracts stances for the member based on the bill and the member's 
    relations.

     Arguments:
        decision: the decision object to initialize
        member: a Member object corresponding to the member who will vote
        bill: a Bill object of the bill to be voted on.
    """

    logger.LOGGER.info("Initializing decision...")

    decision.member = member._id
    decision.bill = bill._id

    if not member.stances:
        member_analyze.extract_voting_stances(member)

    if not member.pro_rel_stances:
        member_analyze.infer_relations_stances(member)

    logger.LOGGER.info("Analyzing alternative positions...")

    decision.for_stances = member_analyze.match_stances(member, bill, outcomes.FOR)
    decision.agn_stances = member_analyze.match_stances(member, bill, outcomes.AGN)

    logger.LOGGER.info("Initialization complete.")
Пример #2
0
    def test_extract_voting_stances(self):
        """ Verifies stances for all bill are extracted."""
        member_analyze.extract_voting_stances(self.member)

        answer = (self.bill1.stances_for + self.bill2.stances_agn +
            self.bill3.stances_for)

        self.assertEqual(len(self.member.stances), len(answer))
        for stance1, stance2 in zip(self.member.stances, answer):
            self.assertTrue(stance1.total_match(stance2))